From: Alexia E. Smith Date: Tue, 16 Apr 2013 20:55:55 +0000 (-0500) Subject: Check for Language::getSpecialPageAliases returning null in SpecialPageFactory X-Git-Tag: 1.31.0-rc.0~15701^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=8cf6365ab2704dc356bcc1dfcf4b1a024abef55e;p=lhc%2Fweb%2Fwiklou.git Check for Language::getSpecialPageAliases returning null in SpecialPageFactory Language::getSpecialPageAliases can return null causing certain methods within SpecialPageFactory that rely on it to raise PHP warnings due to trying to foreach over a non-array. This change will prevent the PHP warning from being raised and allow those functions' error handling to occur normally. Change-Id: I2026c25f12798f699ebc306b12173226270fce2e --- diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 2305f21c98..7304b6d3d4 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -243,11 +243,14 @@ class SpecialPageFactory { $missingPages = clone self::getList(); self::$aliases = array(); - foreach ( $aliases as $realName => $aliasList ) { - foreach ( $aliasList as $alias ) { - self::$aliases[$wgContLang->caseFold( $alias )] = $realName; + // Check for $aliases being an array since Language::getSpecialPageAliases can return null + if ( is_array( $aliases ) ) { + foreach ( $aliases as $realName => $aliasList ) { + foreach ( $aliasList as $alias ) { + self::$aliases[$wgContLang->caseFold( $alias )] = $realName; + } + unset( $missingPages->$realName ); } - unset( $missingPages->$realName ); } foreach ( $missingPages as $name => $stuff ) { self::$aliases[$wgContLang->caseFold( $name )] = $name; @@ -567,13 +570,16 @@ class SpecialPageFactory { } else { // Try harder in case someone misspelled the correct casing $found = false; - foreach ( $aliases as $n => $values ) { - if ( strcasecmp( $name, $n ) === 0 ) { - wfWarn( "Found alias defined for $n when searching for " . - "special page aliases for $name. Case mismatch?" ); - $name = $values[0]; - $found = true; - break; + // Check for $aliases being an array since Language::getSpecialPageAliases can return null + if ( is_array( $aliases ) ) { + foreach ( $aliases as $n => $values ) { + if ( strcasecmp( $name, $n ) === 0 ) { + wfWarn( "Found alias defined for $n when searching for " . + "special page aliases for $name. Case mismatch?" ); + $name = $values[0]; + $found = true; + break; + } } } if ( !$found ) {