/**
* List of special page names to the subclass of SpecialPage which handles them.
*/
- private static $list = array(
+ private static $coreList = array(
// Maintenance Reports
'BrokenRedirects' => 'BrokenRedirectsPage',
'Deadendpages' => 'DeadendPagesPage',
'Userlogout' => 'SpecialUserlogout',
);
+ private static $list;
private static $aliases;
/**
global $wgEnableEmail, $wgEnableJavaScriptTest;
global $wgPageLanguageUseDB;
- if ( !is_object( self::$list ) ) {
+ if ( !is_array( self::$list ) ) {
wfProfileIn( __METHOD__ );
+ self::$list = self::$coreList;
+
if ( !$wgDisableCounters ) {
self::$list['Popularpages'] = 'PopularPagesPage';
}
if ( !is_object( self::$aliases ) ) {
global $wgContLang;
$aliases = $wgContLang->getSpecialPageAliases();
+ $pageList = self::getPageList();
self::$aliases = array();
$keepAlias = array();
// Force every canonical name to be an alias for itself.
- foreach ( self::getPageList() as $name => $stuff ) {
+ foreach ( $pageList as $name => $stuff ) {
$caseFoldedAlias = $wgContLang->caseFold( $name );
self::$aliases[$caseFoldedAlias] = $name;
$keepAlias[$caseFoldedAlias] = 'canonical';
SpecialPageFactory::resetList();
}
+ public function testResetList() {
+ SpecialPageFactory::resetList();
+ $this->assertContains( 'Specialpages', SpecialPageFactory::getNames() );
+ }
+
+ public function testHookNotCalledTwice() {
+ $count = 0;
+ $this->mergeMwGlobalArrayValue( 'wgHooks', array(
+ 'SpecialPage_initList' => array(
+ function () use ( &$count ) {
+ $count++;
+ }
+ ) ) );
+ SpecialPageFactory::resetList();
+ SpecialPageFactory::getNames();
+ SpecialPageFactory::getNames();
+ $this->assertEquals( 1, $count );
+ }
+
public function newSpecialAllPages() {
return new SpecialAllPages();
}
);
}
+ public function testGetAliasListRecursion() {
+ $called = false;
+ $this->mergeMwGlobalArrayValue( 'wgHooks', array(
+ 'SpecialPage_initList' => array(
+ function () use ( &$called ) {
+ SpecialPageFactory::getLocalNameFor( 'Specialpages' );
+ $called = true;
+ }
+ ),
+ ) );
+ SpecialPageFactory::resetList();
+ SpecialPageFactory::getLocalNameFor( 'Specialpages' );
+ $this->assertTrue( $called, 'Recursive call succeeded' );
+ }
+
}