Cleanup r44683 -- fix E_NOTICE bug in MWNamespace::getCanonicalName() instead of...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 16 Dec 2008 23:57:21 +0000 (23:57 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 16 Dec 2008 23:57:21 +0000 (23:57 +0000)
(Also note -- using MWNamespace instead of Namespace for PHP 5.3 compat.)

includes/Namespace.php
includes/api/ApiQuerySiteinfo.php

index 011fc94..3d618e6 100644 (file)
@@ -105,11 +105,15 @@ class MWNamespace {
         * Returns the canonical (English Wikipedia) name for a given index
         *
         * @param $index Int: namespace index
-        * @return string
+        * @return string or false if no canonical definition.
         */
        public static function getCanonicalName( $index ) {
                global $wgCanonicalNamespaceNames;
-               return $wgCanonicalNamespaceNames[$index];
+               if( isset( $wgCanonicalNamespaceNames[$index] ) ) {
+                       return $wgCanonicalNamespaceNames[$index];
+               } else {
+                       return false;
+               }
        }
 
        /**
index 8c7aee3..5e50370 100644 (file)
@@ -127,7 +127,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendNamespaces( $property ) {
-               global $wgContLang, $wgCanonicalNamespaceNames;
+               global $wgContLang;
                $data = array();
                foreach( $wgContLang->getFormattedNamespaces() as $ns => $title )
                {
@@ -135,7 +135,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                'id' => $ns
                        );
                        ApiResult :: setContent( $data[$ns], $title );
-                       $canonical = isset($wgCanonicalNamespaceNames[$ns]) ? $wgCanonicalNamespaceNames[$ns] : false;
+                       $canonical = MWNamespace::getCanonicalName( $ns );
                        
                        if( MWNamespace::hasSubpages( $ns ) )
                                $data[$ns]['subpages'] = '';