From: Brion Vibber Date: Wed, 19 Aug 2009 00:26:59 +0000 (+0000) Subject: Multithreaded rebuild currently relies on PHP's pcntl extension, which is not present... X-Git-Tag: 1.31.0-rc.0~40222 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=639b235e6c74e4f98ee1d3aafea0447fe4520cf3;p=lhc%2Fweb%2Fwiklou.git Multithreaded rebuild currently relies on PHP's pcntl extension, which is not present by default and unsupported on Windows. 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. --- diff --git a/maintenance/rebuildLocalisationCache.php b/maintenance/rebuildLocalisationCache.php index ab19a8debc..d1cff3c2d3 100644 --- a/maintenance/rebuildLocalisationCache.php +++ b/maintenance/rebuildLocalisationCache.php @@ -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