# Upgrade BlueSpice 3 to 4: Global $wgLang is null

**URL:** <https://community.bluespice.com/t/upgrade-bluespice-3-to-4-global-wglang-is-null/87>\
**Category:** Bugs\
**Created:** [February 6, 2024, 12:50pm UTC](https://community.bluespice.com/t/upgrade-bluespice-3-to-4-global-wglang-is-null/87 "2024-02-06T12:50:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djagszent](https://dub1.discourse-cdn.com/flex017/user_avatar/community.bluespice.com/djagszent/32/75_2.png) [@djagszent](https://community.bluespice.com/u/djagszent)\
**Post date:** [February 6, 2024, 12:50pm UTC](https://community.bluespice.com/t/upgrade-bluespice-3-to-4-global-wglang-is-null/87/1 "2024-02-06T12:50:08Z")

</div>

**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](https://www.mediawiki.org/wiki/Manual:$wgLang) 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:

```php
// 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:

```bash
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.

---

<div class="post-metadata">

**Author:** ![danieljonas](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@danieljonas](https://community.bluespice.com/u/danieljonas)\
**Post date:** [May 23, 2024, 7:33am UTC](https://community.bluespice.com/t/upgrade-bluespice-3-to-4-global-wglang-is-null/87/2 "2024-05-23T07:33:35Z")

</div>

Hi @djagszent

thanks for that, but the nm-settings file looks good, the installation is not that old, it comes from version 4.2.4. Any other ideas?

---

<div class="post-metadata">

**Author:** ![danieljonas](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@danieljonas](https://community.bluespice.com/u/danieljonas)\
**Post date:** [May 23, 2024, 7:47am UTC](https://community.bluespice.com/t/upgrade-bluespice-3-to-4-global-wglang-is-null/87/3 "2024-05-23T07:47:26Z")

</div>

Is it better to do the Update from 4.2.4 → 4.3 first and the to 4.4 ?

I am going back to my backup to try it again

---

<div class="post-metadata">

**Author:** ![djagszent](https://dub1.discourse-cdn.com/flex017/user_avatar/community.bluespice.com/djagszent/32/75_2.png) [@djagszent](https://community.bluespice.com/u/djagszent)\
**Post date:** [May 23, 2024, 12:03pm UTC](https://community.bluespice.com/t/upgrade-bluespice-3-to-4-global-wglang-is-null/87/4 "2024-05-23T12:03:16Z")

</div>

You should double check in the database. Execute the following SQL query in the database of the broken system:

```auto
select cast(mwdc_serialized as char) from mwstake_dynamic_config where mwdc_key = 'bs-namespacemanager-namespaces';

```

It will output a PHP serialized array. It is hard to parse but search for the string `_GLOBALS` in there. If you find it, this bug affects you too. If not, then you have another problem.
