Don't emit 404 status code on Special:Redirect
[lhc/web/wiklou.git] / includes / specials / SpecialRunJobs.php
index 286a745..2312f76 100644 (file)
@@ -34,6 +34,10 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                parent::__construct( 'RunJobs' );
        }
 
+       public function doesWrites() {
+               return true;
+       }
+
        public function execute( $par = '' ) {
                $this->getOutput()->disable();
 
@@ -49,8 +53,8 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                        return;
                }
 
-               $optional = array( 'maxjobs' => 0, 'maxtime' => 30, 'type' => false, 'async' => true );
-               $required = array_flip( array( 'title', 'tasks', 'signature', 'sigexpiry' ) );
+               $optional = [ 'maxjobs' => 0, 'maxtime' => 30, 'type' => false, 'async' => true ];
+               $required = array_flip( [ 'title', 'tasks', 'signature', 'sigexpiry' ] );
 
                $params = array_intersect_key( $this->getRequest()->getValues(), $required + $optional );
                $missing = array_diff_key( $required, $params );
@@ -86,16 +90,23 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                        ob_flush();
                        flush();
                        // Once the client receives this response, it can disconnect
+                       set_error_handler( function ( $errno, $errstr ) {
+                               if ( strpos( $errstr, 'Cannot modify header information' ) !== false ) {
+                                       return true; // bug T115413
+                               }
+                               // Delegate unhandled errors to the default handlers
+                               return false;
+                       } );
                }
 
                // Do all of the specified tasks...
                if ( in_array( 'jobs', explode( '|', $params['tasks'] ) ) ) {
                        $runner = new JobRunner( LoggerFactory::getInstance( 'runJobs' ) );
-                       $response = $runner->run( array(
+                       $response = $runner->run( [
                                'type'     => $params['type'],
                                'maxJobs'  => $params['maxjobs'] ? $params['maxjobs'] : 1,
                                'maxTime'  => $params['maxtime'] ? $params['maxjobs'] : 30
-                       ) );
+                       ] );
                        if ( !$params['async'] ) {
                                print FormatJson::encode( $response, true );
                        }