Merge "mw.Upload.BookletLayout/Dialog: Add determinate progress bar"
[lhc/web/wiklou.git] / includes / specialpage / SpecialPageFactory.php
index 4bfe06d..bc2bb31 100644 (file)
@@ -47,7 +47,7 @@ class SpecialPageFactory {
        /**
         * List of special page names to the subclass of SpecialPage which handles them.
         */
-       private static $coreList = array(
+       private static $coreList = [
                // Maintenance Reports
                'BrokenRedirects' => 'BrokenRedirectsPage',
                'Deadendpages' => 'DeadendPagesPage',
@@ -124,6 +124,7 @@ class SpecialPageFactory {
                'ListDuplicatedFiles' => 'ListDuplicatedFilesPage',
 
                // Data and tools
+               'ApiSandbox' => 'SpecialApiSandbox',
                'Statistics' => 'SpecialStatistics',
                'Allmessages' => 'SpecialAllMessages',
                'Version' => 'SpecialVersion',
@@ -135,6 +136,7 @@ class SpecialPageFactory {
                'Randompage' => 'RandomPage',
                'RandomInCategory' => 'SpecialRandomInCategory',
                'Randomredirect' => 'SpecialRandomredirect',
+               'Randomrootpage' => 'SpecialRandomrootpage',
 
                // High use pages
                'Mostlinkedcategories' => 'MostlinkedCategoriesPage',
@@ -176,7 +178,7 @@ class SpecialPageFactory {
                'RunJobs' => 'SpecialRunJobs',
                'Specialpages' => 'SpecialSpecialpages',
                'Userlogout' => 'SpecialUserlogout',
-       );
+       ];
 
        private static $list;
        private static $aliases;
@@ -257,7 +259,7 @@ class SpecialPageFactory {
 
                        // This hook can be used to disable unwanted core special pages
                        // or conditionally register special pages.
-                       Hooks::run( 'SpecialPage_initList', array( &self::$list ) );
+                       Hooks::run( 'SpecialPage_initList', [ &self::$list ] );
 
                }
 
@@ -276,8 +278,8 @@ class SpecialPageFactory {
                        $aliases = $wgContLang->getSpecialPageAliases();
                        $pageList = self::getPageList();
 
-                       self::$aliases = array();
-                       $keepAlias = array();
+                       self::$aliases = [];
+                       $keepAlias = [];
 
                        // Force every canonical name to be an alias for itself.
                        foreach ( $pageList as $name => $stuff ) {
@@ -337,7 +339,7 @@ class SpecialPageFactory {
                if ( isset( $aliases[$caseFoldedAlias] ) ) {
                        $name = $aliases[$caseFoldedAlias];
                } else {
-                       return array( null, null );
+                       return [ null, null ];
                }
 
                if ( !isset( $bits[1] ) ) { // bug 2087
@@ -346,7 +348,7 @@ class SpecialPageFactory {
                        $par = $bits[1];
                }
 
-               return array( $name, $par );
+               return [ $name, $par ];
        }
 
        /**
@@ -387,11 +389,11 @@ class SpecialPageFactory {
                                // @deprecated, officially since 1.18, unofficially since forever
                                wfDeprecated( "Array syntax for \$wgSpecialPages is deprecated ($className), " .
                                        "define a subclass of SpecialPage instead.", '1.18' );
-                               $page = ObjectFactory::getObjectFromSpec( array(
+                               $page = ObjectFactory::getObjectFromSpec( [
                                        'class' => $className,
                                        'args' => $rec,
                                        'closure_expansion' => false,
-                               ) );
+                               ] );
                        } elseif ( $rec instanceof SpecialPage ) {
                                $page = $rec; // XXX: we should deep clone here
                        } else {
@@ -421,7 +423,7 @@ class SpecialPageFactory {
         * @return array ( string => Specialpage )
         */
        public static function getUsablePages( User $user = null ) {
-               $pages = array();
+               $pages = [];
                if ( $user === null ) {
                        global $wgUser;
                        $user = $wgUser;
@@ -447,7 +449,7 @@ class SpecialPageFactory {
         * @return array ( string => Specialpage )
         */
        public static function getRegularPages() {
-               $pages = array();
+               $pages = [];
                foreach ( self::getPageList() as $name => $rec ) {
                        $page = self::getPage( $name );
                        if ( $page->isListed() && !$page->isRestricted() ) {
@@ -466,7 +468,7 @@ class SpecialPageFactory {
         * @return array ( string => Specialpage )
         */
        public static function getRestrictedPages( User $user = null ) {
-               $pages = array();
+               $pages = [];
                if ( $user === null ) {
                        global $wgUser;
                        $user = $wgUser;
@@ -500,7 +502,6 @@ class SpecialPageFactory {
         * @return bool
         */
        public static function executePath( Title &$title, IContextSource &$context, $including = false ) {
-
                // @todo FIXME: Redirects broken due to this call
                $bits = explode( '/', $title->getDBkey(), 2 );
                $name = $bits[0];
@@ -509,8 +510,8 @@ class SpecialPageFactory {
                } else {
                        $par = $bits[1];
                }
+
                $page = self::getPage( $name );
-               // Nonexistent?
                if ( !$page ) {
                        $context->getOutput()->setArticleRelated( false );
                        $context->getOutput()->setRobotPolicy( 'noindex,nofollow' );
@@ -525,6 +526,15 @@ class SpecialPageFactory {
                        return false;
                }
 
+               if ( !$including ) {
+                       // Narrow DB query expectations for this HTTP request
+                       $trxLimits = $context->getConfig()->get( 'TrxProfilerLimits' );
+                       $trxProfiler = Profiler::instance()->getTransactionProfiler();
+                       if ( $context->getRequest()->wasPosted() && !$page->doesWrites() ) {
+                               $trxProfiler->setExpectations( $trxLimits['POST-nonwrite'], __METHOD__ );
+                       }
+               }
+
                // Page exists, set the context
                $page->setContext( $context );