Multithreaded rebuild currently relies on PHP's pcntl extension, which is not present...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 19 Aug 2009 00:26:59 +0000 (00:26 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 19 Aug 2009 00:26:59 +0000 (00:26 +0000)
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.

maintenance/rebuildLocalisationCache.php

index ab19a8d..d1cff3c 100644 (file)
@@ -45,6 +45,18 @@ class RebuildLocalisationCache extends Maintenance {
 
                $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