From 639b235e6c74e4f98ee1d3aafea0447fe4520cf3 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 19 Aug 2009 00:26:59 +0000 Subject: [PATCH] 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. --- maintenance/rebuildLocalisationCache.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.20.1