Merge "Throw exception in importDump instead of dumping a random backtrace and erroring"
[lhc/web/wiklou.git] / includes / MediaWiki.php
index a8bafa3..1b014f6 100644 (file)
@@ -38,7 +38,9 @@ class MediaWiki {
         */
        public function request( WebRequest $x = null ) {
                $old = $this->context->getRequest();
-               $this->context->setRequest( $x );
+               if ( $x ) {
+                       $this->context->setRequest( $x );
+               }
                return $old;
        }
 
@@ -48,7 +50,9 @@ class MediaWiki {
         */
        public function output( OutputPage $x = null ) {
                $old = $this->context->getOutput();
-               $this->context->setOutput( $x );
+               if ( $x ) {
+                       $this->context->setOutput( $x );
+               }
                return $old;
        }
 
@@ -198,7 +202,9 @@ class MediaWiki {
                // Check user's permissions to read this page.
                // We have to check here to catch special pages etc.
                // We will check again in Article::view().
-               $permErrors = $title->getUserPermissionsErrors( 'read', $user );
+               $permErrors = $title->isSpecial( 'RunJobs' )
+                       ? array() // relies on HMAC key signature alone
+                       : $title->getUserPermissionsErrors( 'read', $user );
                if ( count( $permErrors ) ) {
                        // Bug 32276: allowing the skin to generate output with $wgTitle or
                        // $this->context->title set to the input title would allow anonymous users to
@@ -558,7 +564,7 @@ class MediaWiki {
                                        // to fail due to post data being lost, but let's try anyway
                                        // and just log the instance.
                                        //
-                                       // @todo @fixme See if we could issue a 307 or 308 here, need
+                                       // @todo FIXME: See if we could issue a 307 or 308 here, need
                                        // to see how clients (automated & browser) behave when we do
                                        wfDebugLog( 'RedirectedPosts', "Redirected from HTTP to HTTPS: $oldUrl" );
                                }
@@ -660,9 +666,9 @@ class MediaWiki {
                }
 
                if ( !$wgRunJobsAsync ) {
-                       // If running jobs asynchronously has been disabled, run the job here
-                       // while the user waits
-                       SpecialRunJobs::executeJobs( $n );
+                       // Fall back to running the job here while the user waits
+                       $runner = new JobRunner();
+                       $runner->run( array( 'maxJobs'  => $n ) );
                        return;
                }
 
@@ -695,7 +701,8 @@ class MediaWiki {
                if ( !$sock ) {
                        wfDebugLog( 'runJobs', "Failed to start cron API (socket error $errno): $errstr\n" );
                        // Fall back to running the job here while the user waits
-                       SpecialRunJobs::executeJobs( $n );
+                       $runner = new JobRunner();
+                       $runner->run( array( 'maxJobs'  => $n ) );
                        return;
                }