https://bugzilla.wikimedia.org/show_bug.cgi?id=45031

--- Comment #16 from Ori Livneh <[email protected]> ---
(Tim replied on #wikimedia-dev; edited for clarity and reproduced below. --OL)
---


ZeroRatedMobileAccess sets hooks based on a boolean configuration variable.
Obviously you can't do that from the file scope. It should instead have the
configuration variable checks inside unconditionally-registered hook functions,
e.g.:

    static function onCanonicalNamespaces( array &$namespaces ) {
        if ( !$GLOBALS['wgZeroRatedMobileAccessEnableZeroConfigPages'] )
return;
        ...

But most of the content of zero's onCanonicalNamespaces() can be in the file
scope. For example:

    $wgNamespaceContentModels[NS_ZERO] = 'JsonZeroConfig';

This can just be in the file scope. It's harmless to configure a non-existent
namespace. There definitely shouldn't be global variable assignments in a
CanonicalNamespaces hook handler. It's not guaranteed that the hook will be
called before the variables are accessed. What's guaranteed is that there will
be no hook calls between execution of the file scope and setting of the
configuration variables so you can reference configuration globals from hook
functions with confidence.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to