(bug 32434) API allows reblocking the user without reblock parameter.
[lhc/web/wiklou.git] / includes / SpecialPageFactory.php
index 95f75a8..fa1bca4 100644 (file)
@@ -155,7 +155,6 @@ class SpecialPageFactory {
                'Blankpage'                 => 'SpecialBlankpage',
                'Blockme'                   => 'SpecialBlockme',
                'Emailuser'                 => 'SpecialEmailUser',
-               'JavaScriptTest'            => 'SpecialJavaScriptTest',
                'Movepage'                  => 'MovePageForm',
                'Mycontributions'           => 'SpecialMycontributions',
                'Mypage'                    => 'SpecialMypage',
@@ -178,7 +177,7 @@ class SpecialPageFactory {
        static function getList() {
                global $wgSpecialPages;
                global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
-               global $wgEnableEmail;
+               global $wgEnableEmail, $wgEnableJavaScriptTest;
 
                if ( !is_object( self::$mList ) ) {
                        wfProfileIn( __METHOD__ );
@@ -200,6 +199,10 @@ class SpecialPageFactory {
                                self::$mList['ChangeEmail'] = 'SpecialChangeEmail';
                        }
 
+                       if( $wgEnableJavaScriptTest ) {
+                               self::$mList['JavaScriptTest'] = 'SpecialJavaScriptTest';
+                       }
+
                        // Add extension special pages
                        self::$mList = array_merge( self::$mList, $wgSpecialPages );
 
@@ -368,13 +371,17 @@ class SpecialPageFactory {
                        global $wgUser;
                        $user = $wgUser;
                }
+               $context = RequestContext::newExtraneousContext( Title::newMainPage() );
+               $context->setUser( $user );
                foreach ( self::getList() as $name => $rec ) {
                        $page = self::getPage( $name );
-                       if ( $page // not null
-                               && $page->isListed()
-                               && ( !$page->isRestricted() || $page->userCanExecute( $user ) )
-                       ) {
-                               $pages[$name] = $page;
+                       if ( $page ) { // not null
+                               $page->setContext( $context );
+                               if ( $page->isListed()
+                                       && ( !$page->isRestricted() || $page->userCanExecute( $user ) )
+                               ) {
+                                       $pages[$name] = $page;
+                               }
                        }
                }
                return $pages;