http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90096

Revision: 90096
Author:   krinkle
Date:     2011-06-14 22:49:38 +0000 (Tue, 14 Jun 2011)
Log Message:
-----------
wgNamespaceIds in JavaScript didn't include canonical namespaces. Adding them 
to it, in a similar way that Language->getNamespaceIds does it for the 
localized namespaces and the namespace aliases.

Fixes bug in mw.Title constructor when .setNamespace() is used with a canonical 
namespace on a non-English content-language wiki.
Example: On a German wiki "var foo = new mw.Title('bar').setNamespace('file')" 
will throw an Error, as wgNamespaceIds only contains localized namespaces + 
namespace aliases, not canonical ones (in contrary to the assumption that has 
been made in various places).

(bug 25375) Add canonical namespaces to JavaScript "wgNamespaceIds" 

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES-1.19
    trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php

Modified: trunk/phase3/RELEASE-NOTES-1.19
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.19     2011-06-14 22:36:08 UTC (rev 90095)
+++ trunk/phase3/RELEASE-NOTES-1.19     2011-06-14 22:49:38 UTC (rev 90096)
@@ -91,6 +91,7 @@
   as lastTabIndex().
 * (bug 29332) Warn if user requests mediawiki-announce subscription but does 
not
   enter an e-mail address.
+* (bug 25375) Add canonical namespaces to JavaScript "wgNamespaceIds" 
 
 === API changes in 1.19 ===
 * BREAKING CHANGE: action=watch now requires POST and token.

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php        
2011-06-14 22:36:08 UTC (rev 90095)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php        
2011-06-14 22:49:38 UTC (rev 90096)
@@ -55,6 +55,14 @@
                );
                $mainPage = Title::newMainPage();
 
+               // Build wgNamespaceIds
+               // A complete key-value pair object mapping localized, 
canonical and aliases for namespaces
+               // to their numerical ids (case insensitive and with 
underscores)
+               $namespaceIds = $wgContLang->getNamespaceIds();
+               foreach( MWNamespace::getCanonicalNamespaces() as $index => 
$name ) {
+                       $nsIds[$wgContLang->lc( $name )] = $index;
+               }
+
                // Build list of variables
                $vars = array(
                        'wgLoadScript' => $wgLoadScript,
@@ -81,7 +89,7 @@
                        'wgDigitTransformTable' => $compactDigitTransTable,
                        'wgMainPageTitle' => $mainPage ? 
$mainPage->getPrefixedText() : null,
                        'wgFormattedNamespaces' => 
$wgContLang->getFormattedNamespaces(),
-                       'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
+                       'wgNamespaceIds' => $namespaceIds,
                        'wgSiteName' => $wgSitename,
                        'wgFileExtensions' => array_values( $wgFileExtensions ),
                        'wgDBname' => $wgDBname,


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to