r55294 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55293‎ | r55294 | r55295 >
Date:00:26, 19 August 2009
Author:brion
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/maintenance/rebuildLocalisationCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildLocalisationCache.php
@@ -45,6 +45,18 @@
4646
4747 $force = $this->hasOption('force');
4848 $threads = $this->getOption( 'threads', 1 );
 49+ if( $threads < 1 || $threads != intval( $threads ) ) {
 50+ $this->output( "Invalid thread count specified; running single-threaded.\n" );
 51+ $threads = 1;
 52+ }
 53+ if( $threads > 1 && wfIsWindows() ) {
 54+ $this->output( "Threaded rebuild is not supported on Windows; running single-threaded.\n" );
 55+ $threads = 1;
 56+ }
 57+ if( $threads > 1 && !function_exists( 'pcntl_fork' ) ) {
 58+ $this->output( "PHP pcntl extension is not present; running single-threaded.\n" );
 59+ $threads = 1;
 60+ }
4961
5062 $conf = $wgLocalisationCacheConf;
5163 $conf['manualRecache'] = false; // Allow fallbacks to create CDB files

Status & tagging log