API: Allow undeleting files
[lhc/web/wiklou.git] / includes / MediaWiki.php
index 1c245c1..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
@@ -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;
                }