X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FSpecialPageFactory.php;h=53cef7f723536c1df22b66ce8ff07c08b82dca5f;hb=84e454da79f4968fc5a47a5b2c5b0729a543bd46;hp=18793e3f7972c3f4d5919000ee1e82fdb03edac6;hpb=2e09c356789bf7569fdfa219827f488976aa16f0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 18793e3f79..53cef7f723 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -79,6 +79,7 @@ class SpecialPageFactory { 'Categories' => 'SpecialCategories', 'Listredirects' => 'ListredirectsPage', 'PagesWithProp' => 'SpecialPagesWithProp', + 'TrackingCategories' => 'SpecialTrackingCategories', // Login/create account 'Userlogin' => 'LoginForm', @@ -231,7 +232,7 @@ class SpecialPageFactory { * aliases; the first in the array is the canonical alias. All registered special * pages are guaranteed to have a property entry, and for that property array to * contain at least one entry (English fallbacks will be added if necessary). - * @return Object + * @return object */ static function getAliasList() { if ( !is_object( self::$aliases ) ) { @@ -242,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; @@ -360,7 +364,7 @@ class SpecialPageFactory { * Return categorised listable special pages which are available * for the current user, and everyone. * - * @param $user User object to check permissions, $wgUser will be used if + * @param User $user User object to check permissions, $wgUser will be used if * if not provided * @return array ( string => Specialpage ) */ @@ -406,17 +410,21 @@ class SpecialPageFactory { * Return categorised listable special pages which are available * for the current user, but not for everyone * + * @param User|null $user User object to use or null for $wgUser * @return array ( string => Specialpage ) */ - public static function getRestrictedPages() { - global $wgUser; + public static function getRestrictedPages( User $user = null ) { $pages = array(); + if ( $user === null ) { + global $wgUser; + $user = $wgUser; + } foreach ( self::getList() as $name => $rec ) { $page = self::getPage( $name ); if ( $page->isListed() && $page->isRestricted() - && $page->userCanExecute( $wgUser ) + && $page->userCanExecute( $user ) ) { $pages[$name] = $page; } @@ -566,13 +574,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 ) {