Upgrade BlueSpice 3 to 4: Global $wgLang is null

Issue
After upgrading a relativ old BlueSpice installation (first setup 2014) nothing was working and I got strange error messages. The most prominent that all kind of extensions expected to find the Manual:$wgLang - MediaWiki global but the StubObject could not be upgraded to the real Language class.

After some debugging it turns out: the mwstake/mediawiki-component-dynamicconfig component was overwriting the complete $GLOBALS - so $wgLang is null afterwards.

The extensions/BlueSpiceFoundation/config/nm-settings.php file of the BlueSpice 3 instalation has entries like these in there:

// START Namespace NS_NR_BETRIEBLICHE_ABLäUFE
if( !defined( "NS_NR_BETRIEBLICHE_ABLäUFE" ) ) define("NS_NR_BETRIEBLICHE_ABLäUFE", 3002);
$GLOBALS['GLOBALS']['wgExtraNamespaces'][NS_NR_BETRIEBLICHE_ABLäUFE] = 'NR_Betriebliche_Abläufe';
$GLOBALS['GLOBALS']['wgNamespacesWithSubpages'][NS_NR_BETRIEBLICHE_ABLäUFE] = true;
$GLOBALS['GLOBALS']['wgVisualEditorAvailableNamespaces'][NS_NR_BETRIEBLICHE_ABLäUFE] = false;
$GLOBALS['GLOBALS']['smwgNamespacesWithSemanticLinks'][NS_NR_BETRIEBLICHE_ABLäUFE] = false;
$GLOBALS['GLOBALS']['wgNamespaceAliases']['NR_Betriebliche_Abläufe'] = NS_NR_BETRIEBLICHE_ABLäUFE;
// END Namespace NS_NR_BETRIEBLICHE_ABLäUFE

Mind the useless but hamless $GLOBALS['GLOBALS'] instead of $GLOBALS. Looks like at least in one point in time the nm-settings.php file was written this way.

The migration process (BlueSpice\NamespaceManager\Maintenance\MigrateNmSettings::parseGlobals) does not account for this way of updating the globals. Thus it migrated this file so that the whole $GLOABLS['GLOBALS'] global variable (i.e. just $GLOBALS) gets replaced by BlueSpice\NamespaceManager\DynamicConfig\NamespaceSettings with useless stuff.

Workaround
Before upgrading to BlueSpice 4 execute the following in a terminal:

sed -i -e "s/GLOBALS\\['GLOBALS'\\]/GLOBALS/g" extensions/BlueSpiceFoundation/config/nm-settings.php

to remove the useless ['GLOBALS'] from the file. Then the migration creates the right configuration.

2 Likes