Rather than just spitting out a fatal error, let's gracefully fall back to single threading and tell the user why.
(Also now actually validating the thread number, though a maximum might be wise. ;)
Note that this could be implemented without pcntl instead by shelling out to subprocesses.
$force = $this->hasOption('force');
$threads = $this->getOption( 'threads', 1 );
+ if( $threads < 1 || $threads != intval( $threads ) ) {
+ $this->output( "Invalid thread count specified; running single-threaded.\n" );
+ $threads = 1;
+ }
+ if( $threads > 1 && wfIsWindows() ) {
+ $this->output( "Threaded rebuild is not supported on Windows; running single-threaded.\n" );
+ $threads = 1;
+ }
+ if( $threads > 1 && !function_exists( 'pcntl_fork' ) ) {
+ $this->output( "PHP pcntl extension is not present; running single-threaded.\n" );
+ $threads = 1;
+ }
$conf = $wgLocalisationCacheConf;
$conf['manualRecache'] = false; // Allow fallbacks to create CDB files