r55659 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55658‎ | r55659 | r55660 >
Date:19:32, 28 August 2009
Author:btongminh
Status:ok
Tags:
Comment:
Fix wfShellBackgroundExec for windows. Works in maintenance/eval.php mode, have not tested when running php as webserver module.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2346,21 +2346,24 @@
23472347 }
23482348
23492349 /**
2350 - * Executes a shell command in the background. Passes back the PID of the operation
 2350+ * Executes a shell command in the background. Returns true of successful.
23512351 *
2352 - * FIXME: Does not work on Windows; does not work at all (See CodeReview r55575)
2353 - *
23542352 * @param $cmd String
23552353 */
2356 -function wfShellBackgroundExec( $cmd ){
 2354+function wfShellBackgroundExec( $cmd ) {
23572355 wfDebug( "wfShellBackgroundExec: $cmd\n" );
23582356
23592357 if ( ! wfShellExecEnabled() ) {
2360 - return "Unable to run external programs";
 2358+ return false;
23612359 }
23622360
2363 - $pid = shell_exec( "nohup $cmd > /dev/null & echo $!" );
2364 - return $pid;
 2361+ if ( wfIsWindows() ) {
 2362+ shell_exec( "start /b $cmd >nul");
 2363+ return true;
 2364+ } else {
 2365+ $pid = shell_exec( "nohup $cmd > /dev/null & echo $!" );
 2366+ return (bool)$pid;
 2367+ }
23652368 }
23662369
23672370 /**

Status & tagging log