Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / specials / SpecialRunJobs.php
index eeaf2d3..761610e 100644 (file)
@@ -40,27 +40,23 @@ class SpecialRunJobs extends UnlistedSpecialPage {
 
        public function execute( $par = '' ) {
                $this->getOutput()->disable();
-
                if ( wfReadOnly() ) {
-                       // HTTP 423 Locked
-                       HttpStatus::header( 423 );
-                       print 'Wiki is in read-only mode';
-
+                       wfHttpError( 423, 'Locked', 'Wiki is in read-only mode.' );
                        return;
                } elseif ( !$this->getRequest()->wasPosted() ) {
-                       HttpStatus::header( 400 );
-                       print 'Request must be POSTed';
+                       wfHttpError( 400, 'Bad Request', 'Request must be POSTed.' );
                        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 );
                if ( count( $missing ) ) {
-                       HttpStatus::header( 400 );
-                       print 'Missing parameters: ' . implode( ', ', array_keys( $missing ) );
+                       wfHttpError( 400, 'Bad Request',
+                               'Missing parameters: ' . implode( ', ', array_keys( $missing ) )
+                       );
                        return;
                }
 
@@ -72,8 +68,7 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                $verified = is_string( $providedSignature )
                        && hash_equals( $correctSignature, $providedSignature );
                if ( !$verified || $params['sigexpiry'] < time() ) {
-                       HttpStatus::header( 400 );
-                       print 'Invalid or stale signature provided';
+                       wfHttpError( 400, 'Bad Request', 'Invalid or stale signature provided.' );
                        return;
                }
 
@@ -94,19 +89,22 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                                if ( strpos( $errstr, 'Cannot modify header information' ) !== false ) {
                                        return true; // bug T115413
                                }
-                               // Delegate unhandled errors to the default handlers
-                               return false;
+                               // Delegate unhandled errors to the default MediaWiki handler
+                               // so that fatal errors get proper logging (T89169)
+                               return call_user_func_array(
+                                       'MWExceptionHandler::handleError', func_get_args()
+                               );
                        } );
                }
 
                // 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 );
                        }