r57729 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57728‎ | r57729 | r57730 >
Date:21:51, 14 October 2009
Author:dale
Status:ok (Comments)
Tags:
Comment:
* follow-up to r57728 switched to use global wfShellExec function
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadBase.php
@@ -813,11 +813,7 @@
814814 # that does not seem to be worth the pain.
815815 # Ask me (Duesentrieb) about it if it's ever needed.
816816 $output = array();
817 - if ( wfIsWindows() ) {
818 - $output = wfRunExternal($command, $exitCode);
819 - } else {
820 - exec( "$command 2>&1", $output, $exitCode );
821 - }
 817+ $output = wfShellExec($command, $exitCode);
822818
823819
824820 # map exit code to AV_xxx constants.
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3346,55 +3346,3 @@
33473347 $langCode = implode ( '-' , $codeBCP );
33483348 return $langCode;
33493349 }
3350 -
3351 -/* Fixes shell_exec problems on Windows
3352 - * From http://www.php.net/manual/de/function.shell-exec.php#52826 via bug 21140
3353 - */
3354 -function wfRunExternal($cmd,&$code) {
3355 - $descriptorspec = array(
3356 - 0 => array("pipe", "r"), // stdin is a pipe that the child will read from
3357 - 1 => array("pipe", "w"), // stdout is a pipe that the child will write to
3358 - 2 => array("pipe", "w") // stderr is a file to write to
3359 - );
3360 -
3361 - $pipes= array();
3362 - $process = proc_open($cmd, $descriptorspec, $pipes);
3363 -
3364 - $output= "";
3365 -
3366 - if (!is_resource($process)) return false;
3367 -
3368 - #close child's input imidiately
3369 - fclose($pipes[0]);
3370 -
3371 - stream_set_blocking($pipes[1],false);
3372 - stream_set_blocking($pipes[2],false);
3373 -
3374 - $todo= array($pipes[1],$pipes[2]);
3375 -
3376 - while( true ) {
3377 - $read= array();
3378 - if( !feof($pipes[1]) ) $read[]= $pipes[1];
3379 - if( !feof($pipes[2]) ) $read[]= $pipes[2];
3380 -
3381 - if (!$read) break;
3382 -
3383 - $ready= stream_select($read, $write=NULL, $ex= NULL, 2);
3384 -
3385 - if ($ready === false) {
3386 - break; #should never happen - something died
3387 - }
3388 -
3389 - foreach ($read as $r) {
3390 - $s= fread($r,1024);
3391 - $output.= $s;
3392 - }
3393 - }
3394 -
3395 - fclose($pipes[1]);
3396 - fclose($pipes[2]);
3397 -
3398 - $code= proc_close($process);
3399 -
3400 - return $output;
3401 -}

Follow-up revisions

RevisionCommit summaryAuthorDate
r57801fix per r57729#c4267dale04:38, 16 October 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57728* (bug 21140) Fixed Upload Form for using an Antivirus Program on Windowsdale21:39, 14 October 2009

Comments

#Comment by Platonides (talk | contribs)   17:40, 15 October 2009

As we talked on #mediawiki, this should be $output = wfShellExec("$command 2>&1", $exitCode); not $output = wfShellExec($command, $exitCode);

#Comment by Mdale (talk | contribs)   04:44, 16 October 2009

~~ r57801

Status & tagging log