mediawiki4intranet / Wikilog

Heavily improved Wikilog extension
http://wiki.4intra.net/Wikilog
GNU General Public License v2.0
10 stars 10 forks source link

Dealing with undefined languages in $namespaceNames #8

Closed jneug closed 8 years ago

jneug commented 8 years ago

I'm using Wikilog on a German (de) wiki and the Blog namespace is not setup properly. Since de is not defined in $namespaceNames, an error is thrown at Wikilog.php#L277.

Additionally, I'm getting an Unsupported operand types error for using += at that line.

I tested this locally on MediaWiki 1.25.3, PHP 5.6.10 (MAMP 3.4), MySQL 5.5.42.

I fixed both problems by replacing lines 277 and 278 with

        if( array_key_exists($wgLanguageCode, $namespaceNames) ) {
            $wgExtraNamespaces = $wgExtraNamespaces + $namespaceNames[$wgLanguageCode];
        } else {
            $wgExtraNamespaces = $wgExtraNamespaces + $namespaceNames['en'];
        }
        $wgNamespaceAliases = $wgNamespaceAliases + array_flip($namespaceNames['en']);

and here are German translations for the namespaces:

/** German (Deutsch) */
$namespaceNames['de'] = array(
    NS_BLOG => 'Blog',
    NS_BLOG_TALK => 'Blog Diskussion',
);
vitalif commented 8 years ago

Thanks, that was a recent fix for namespace localisation that introduced the bug :)