Fix wfShellBackgroundExec for windows. Works in maintenance/eval.php mode, have not...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 28 Aug 2009 19:32:07 +0000 (19:32 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 28 Aug 2009 19:32:07 +0000 (19:32 +0000)
includes/GlobalFunctions.php

index 7b98ed6..e1eb6ab 100644 (file)
@@ -2346,21 +2346,24 @@ function wfShellExec( $cmd, &$retval=null ) {
 }
 
 /**
- * Executes a shell command in the background. Passes back the PID of the operation 
- *
- * FIXME: Does not work on Windows; does not work at all (See CodeReview r55575)
+ * Executes a shell command in the background. Returns true of successful. 
  *
  * @param $cmd String
  */
-function wfShellBackgroundExec( $cmd )       
+function wfShellBackgroundExec( $cmd ) {       
        wfDebug( "wfShellBackgroundExec: $cmd\n" );
        
        if ( ! wfShellExecEnabled() ) {
-               return "Unable to run external programs";
+               return false;
        }
        
-       $pid = shell_exec( "nohup $cmd > /dev/null & echo $!" );
-       return $pid;
+       if ( wfIsWindows() ) {
+               shell_exec( "start /b $cmd >nul");
+               return true;
+       } else {
+               $pid = shell_exec( "nohup $cmd > /dev/null & echo $!" );
+               return (bool)$pid;
+       }
 }
 
 /**