Last modified: 2014-01-09 14:40:14 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T60182, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 58182 - Namespace constants can no longer be used directly in LocalSettings
Namespace constants can no longer be used directly in LocalSettings
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
master
All All
: High blocker (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 58190
  Show dependency treegraph
 
Reported: 2013-12-08 15:15 UTC by Jeroen De Dauw
Modified: 2014-01-09 14:40 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jeroen De Dauw 2013-12-08 15:15:36 UTC
Got the following error when updating SMW wiki to SMW master: http://pastebin.com/HY5gMiam

Modification of settings using the namespace consonants still needs to be
delayed. I had to do this (below) to address the issue, and presumably there are quite a few more settings in which those constants might be used, and that thus need to be modified at a later point.

$wgExtensionFunctions[] = function() {
        global $wgContentNamespaces;
        $wgContentNamespaces = array( NS_MAIN, NS_HELP, NS_CATEGORY,
SMW_NS_PROPERTY, SMW_NS_TYPE, SMW_NS_CONCEPT );

        // setup namespace search
        global $wgNamespacesToBeSearchedDefault;
        $wgNamespacesToBeSearchedDefault[NS_HELP] = true;
        $wgNamespacesToBeSearchedDefault[SMW_NS_TYPE] = true;
        $wgNamespacesToBeSearchedDefault[SMW_NS_PROPERTY] = true;

        // setup namespace protection for documentation
        global $wgNamespaceProtection;
        $wgNamespaceProtection[NS_HELP] = array('docu');
        $wgNamespaceProtection[SMW_NS_TYPE] = array('docu');
        $wgNamespaceProtection[NS_PROJECT] = array('docu');

        return true;
};

In case those settings are SMW specific, I'm guessing we run into the earlier
issue again, where SMW starts using the config before the delayed modification
in LS happens.

We likely cannot get rid of this, in which case it should be clearly documented.
Comment 1 Jeroen De Dauw 2013-12-08 15:17:26 UTC
This is unfortunate. I cannot add SMW 1.9 as target? :( Easily done on GH...
Comment 2 MWJames 2013-12-08 22:18:38 UTC
## Issue
SNW-NS constants [0] are delayed due to $smwgNamespaceIndex being a prerequisite and its initialization has to happen first before [1] can be processed.

## Solution
Use [2] as an approach in LocalSettings to delay initialization.

[0] SMW_NS_PROPERTY, SMW_NS_TYPE, SMW_NS_CONCEPT 

[1] SMW\NamespaceCustomizer

[2] $GLOBALS['wgExtensionFunctions'][] = function() {

    // Add settings relevant for after SMW intialization

    $GLOBALS['wgNamespacesToBeSearchedDefault'] = array(
        SMW_NS_PROPERTY => true,
    );

}
Comment 3 MWJames 2013-12-08 22:21:41 UTC
$wgContentNamespaces, $wgNamespacesToBeSearchedDefault and $wgNamespaceProtection are known configuration variables that can hold a [0] reference.

Please feel free to add additional settings that can contain [0].

[0] SMW_NS_PROPERTY, SMW_NS_TYPE, SMW_NS_CONCEPT
Comment 4 MWJames 2013-12-12 03:21:02 UTC
Delayed settings are no longer necessary for LocalSettings, as long as you add enableSemantics() to LocalSettings before any configuration is making a reference to a SMW namespace [1].

If by any occasion settings rely on a different NS index (other than 102 etc.), $smwgNamespaceIndex has to be declared before enableSemantics() in order for the namespace to set the correct Id.

Related change [2].

[1] SMW_NS_PROPERTY, SMW_NS_TYPE, SMW_NS_CONCEPT

[2] https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/47
Comment 5 [[kgh]] 2014-01-09 14:40:14 UTC
It must be noted that, if you are using MW ≤ 1.21.x, you have to invoke the Extension installer extension with

  include "extensions/ExtensionInstaller/ExtensionInstaller.php";

before declaring 

  enableSemantics( 'example.org' )

Otherwise you will naturally be getting a

  PHP Fatal error:  Call to undefined function enableSemantics()

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links