From 2f1cee5b91d405b4815c6bd464c498a59599059f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 16 Dec 2008 23:57:21 +0000 Subject: [PATCH] Cleanup r44683 -- fix E_NOTICE bug in MWNamespace::getCanonicalName() instead of replicating the function. :) (Also note -- using MWNamespace instead of Namespace for PHP 5.3 compat.) --- includes/Namespace.php | 8 ++++++-- includes/api/ApiQuerySiteinfo.php | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/Namespace.php b/includes/Namespace.php index 011fc949e2..3d618e649f 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -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; + } } /** diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 8c7aee33d9..5e503709e3 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -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'] = ''; -- 2.20.1