phpcs: More require/include is not a function
[lhc/web/wiklou.git] / maintenance / runJobs.php
index abe8335..0f4c184 100644 (file)
@@ -25,7 +25,7 @@
  * @ingroup Maintenance
  */
 
-require_once( __DIR__ . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
 
 /**
  * Maintenance script that runs pending jobs.
@@ -61,10 +61,11 @@ class RunJobs extends Maintenance {
                        $procs = intval( $this->getOption( 'procs' ) );
                        if ( $procs < 1 || $procs > 1000 ) {
                                $this->error( "Invalid argument to --procs", true );
-                       }
-                       $fc = new ForkController( $procs );
-                       if ( $fc->start() != 'child' ) {
-                               exit( 0 );
+                       } elseif ( $procs != 1 ) {
+                               $fc = new ForkController( $procs );
+                               if ( $fc->start() != 'child' ) {
+                                       exit( 0 );
+                               }
                        }
                }
                $maxJobs = $this->getOption( 'maxjobs', false );
@@ -94,13 +95,16 @@ class RunJobs extends Maintenance {
 
                                // Run the job...
                                $t = microtime( true );
+                               wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
                                try {
                                        $status = $job->run();
                                        $error = $job->getLastError();
                                } catch ( MWException $e ) {
                                        $status = false;
                                        $error = get_class( $e ) . ': ' . $e->getMessage();
+                                       wfDebugLog( 'exception', $e->getLogMessage() );
                                }
+                               wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
                                $timeMs = intval( ( microtime( true ) - $t ) * 1000 );
 
                                // Mark the job as done on success or when the job cannot be retried
@@ -108,7 +112,7 @@ class RunJobs extends Maintenance {
                                        $group->ack( $job ); // done
                                }
 
-                               if ( !$status ) {
+                               if ( $status === false ) {
                                        $this->runJobsLog( $job->toString() . " t=$timeMs error={$error}" );
                                } else {
                                        $this->runJobsLog( $job->toString() . " t=$timeMs good" );
@@ -145,4 +149,4 @@ class RunJobs extends Maintenance {
 }
 
 $maintClass = "RunJobs";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;