New revs - Public comments

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: New revs - Public comments
« Reply #150, on September 28th, 2011, 07:58 PM »
- Convert to is_dir, then?
- Okay!
- What does the 'be insert' mean, if it's not a typo....? :unsure:

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #153, on September 28th, 2011, 08:08 PM »
"User might insert 5, or 5.3, or 5.3.0" or something to that effect.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: New revs - Public comments
« Reply #154, on September 28th, 2011, 09:38 PM »
+   $params = array(&$boardIndexOptions);
+   if ($boardIndexOptions)
+      $params[] = &$categories;
+   else
+      $params[] = &$this_category;
+   call_hook('get_boardindex', $params);

I'm assuming you meant to test for include_categories...?

Wouldn't that be simpler (and more accurate)?

Code: [Select]
call_hook('get_boardindex', array(&$boardIndexOptions, $boardIndexOptions['include_categories'] ? &$categories : &$this_category));

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #155, on September 28th, 2011, 09:40 PM »
Yes, I meant to test for that. No, you can't do what you suggest, I tried it originally and PHP complained bitterly.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: New revs - Public comments
« Reply #156, on September 28th, 2011, 09:56 PM »
- Does that mean I need to test your 3000 lines thoroughly? :P I'm kind of skipping through the large functions because they seem to be okay and I'm mainly focusing on the smaller things outside these functions, such as this... Please don't tell me I have to spend my week on that... :^^;: I still have 1600 lines left to check...

- Yeah, I remembered in the meantime: the official syntax is "$a =& $b", not "$a = &$b", because that's really "=&" and it basically says that $a is an alias to $b, and $b is an alias to $a just the same, so it's not really the same to PHP...
Posted: September 28th, 2011, 09:50 PM

There are some beautiful pieces of code in your table creation function, btw :)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #157, on September 28th, 2011, 09:58 PM »
I wouldn't worry about testing the code thoroughly because what will happen is that I'll be testing it by writing add-ons which will show up different weaknesses in the code, e.g. how live reported an issue with ENUM handling in the DB code, and the more hammering it gets with add-ons, the more thoroughly it's all going to be shaken out.

It might not hurt to write unit tests for the add-on manager.

And thanks :) I did try to construct something that would handle what I was going to throw at it, and it reverts one of the irritations I had in later SMF releases that the code was removed instead of fixing it.
Re: New revs - Public comments
« Reply #158, on October 2nd, 2011, 06:18 PM »
Some interesting things in r1049.

Probably the first one which occurs to me is:
Quote
Also note that $admin_areas is now a global, so the admin menu hook doesn't need to specify it as a param.
Why? It wasn't part of $context originally for a reason: security. The only way it could be modified was through the defined hook, because as soon as it's been back from the hook, housekeeping is done then it's sent off to createMenu, whereupon it is discarded.
Quote
if you modify the admin menu, you'll need to manually remove the cache file, or run clean_cache('css', 'admenu') through a hook or something.
I'd rather automate that if possible. While it's not particularly ideal to sit and retest the entire menu structure for changes, if it's been to a hook, the hook is going to have added some items which will likely negate the cache.

What, exactly, is cached here? (I haven't looked yet.) I wasn't that fond in SMF of having things cached after hooks had been run, it seemed to defy the point of having per-run hooks and can lead to messiness after things have been disabled or even enabled. (Perhaps the plugin enable/disable steps should also clean cache generally anyway.)

That said, it seems to be purely CSS cached here, in which case only plugins that do... something... with CSS need to clear it? Let me know exactly what's being cached, or I'll figure it out from the source, whichever happens first, and I can then make a judgement as to whether the plugin manager should do that automatically or whether plugins that make a change there need to deal with it.
Quote
Added three icons to the topic moderation menu. Only visible to members with the correct permissions.
Icons are good. Unless they look massively out of place, they'll probably be fine and might encourage us to iconify the rest, which is generally a good thing.
Quote
Package functions don't need to declare admin.css, since it's already declared by that time. (PackageGet.php, Packages.php)
I wouldn't worry too much about maintaining these files. As things evolve, these two plus Subs-Package are going to be phased out anyway.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: New revs - Public comments
« Reply #159, on October 3rd, 2011, 12:19 AM »
Quote from Arantor on October 2nd, 2011, 06:18 PM
Quote
Also note that $admin_areas is now a global, so the admin menu hook doesn't need to specify it as a param.
Why? It wasn't part of $context originally for a reason: security. The only way it could be modified was through the defined hook, because as soon as it's been back from the hook, housekeeping is done then it's sent off to createMenu, whereupon it is discarded.
Its lifetime is the same. I globaled it so that it could be used in dynamic_admin_menu_icons or something. As soon as the unique hook is called and the menu is create -- that array goes away, too.
Quote
Quote
if you modify the admin menu, you'll need to manually remove the cache file, or run clean_cache('css', 'admenu') through a hook or something.
I'd rather automate that if possible. While it's not particularly ideal to sit and retest the entire menu structure for changes, if it's been to a hook, the hook is going to have added some items which will likely negate the cache.
It's only an icon cache... I'm caching ALL of the icons in the array, regardless of whether they can be shown to the user. Small enough anyway.

As for the loadBlock stuff, it's going to have to wait until tomorrow. I noticed another bug in the index rebuilder -- if it's called more than once, it erases the skeleton :(

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #160, on October 3rd, 2011, 12:23 AM »
Quote
It's only an icon cache... I'm caching ALL of the icons in the array, regardless of whether they can be shown to the user. Small enough anyway.
Therein lies the problem. A plugin may or may not call an icon, and it may or may not call an icon from its own folder (but reuse an existing one) - but the list of possible icons may be the same call to call.

I still haven't looked at the code, but I really hope it's checking whether it's a URL or not, because otherwise it's likely to be calling for a plugin's icon(s) through an external URL request only to be served locally... (I couldn't see any way of passing just a filename to the menu builder and for it to be able to cope with it, so the menu builder looks to see if it's a URL or not, and if not, serves it from the theme as normal)

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: New revs - Public comments
« Reply #161, on October 3rd, 2011, 08:01 AM »
That's the thing. It checks for urls first. Meaning this is never a real problem.

Holy fuck I'm stuck to bed for now. My legs hurt horribly after a ridiculous attempt to ahem, jog...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #162, on October 3rd, 2011, 10:52 AM »
Jogging is harsh :/

Anything in particular you'd like me to look over in r1049 since you flagged it as wanting feedback?

Also, I've committed the RelaxNG spec I've been referring to. It should validate current plugin-info.xml files - that should cover everything currently supported in the plugin manager, as well as validating new columns and indexes for existing tables, which is currently not supported.
Re: New revs - Public comments
« Reply #163, on October 3rd, 2011, 11:09 AM »
Although, I'm getting pretty fed up when one tool validates both my RNG schema and a big scary file against it but PHP's XMLReader won't because of 'Extra element database in interleave' when there really isn't - and, just for fun, if I comment out the <tables> construct inside <database>, it works as expected :/
Re: New revs - Public comments
« Reply #164, on October 3rd, 2011, 12:08 PM »
I figured out the problem with the above, mostly it's because libxml2 is more strict than <oXygen/> XML editor is.

For those who've written a plugin thus far, you can crudely test it with:
Code: [Select]
<?php
$schema 
'/path/to/other/plugin-info.rng';
$document '/path/to/plugin-info.xml';
$xml_reader = new XMLReader();
$xml_reader->open($document);
$xml_reader->setRelaxNGSchema($schema);

$valid true;
while (
$xml_reader->read())
if (!$xml_reader->isValid())
$valid false;

var_dump($valid);
?>

Note that you set the schema after you load the document, as opposed to the more traditional approach of stating the schema actually in the file like you would through a DOCTYPE.