"Aaron Schulz" posted a comment on MediaWiki.r113688.
URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/113688#c32260
Commit summary for MediaWiki.r113688:
Made wfShellMaintenanceCmd() not totally broken due to excess shell escaping.
Aaron Schulz's comment:
I was messing around with this some more. shell_exec seems to work fine without
or without the quotes. the popen() type functions are more interesting. I tried:
<source lang="php">
<?php
#$r = popen( '"php" "C:\wamp\www\MW_trunk/maintenance/showStats.php"', 'r' );
#var_dump( stream_get_contents( $r ) );
$pipes = array();
$process = proc_open(
'"php" "C:\wamp\www\MW_trunk/maintenance/showStats.php"',
#'php C:\wamp\www\MW_trunk/maintenance/showStats.php',
array(
0 => array( 'pipe', 'r' ), // input
1 => array( 'pipe', 'w' ), // output
2 => array( 'file', 'NUL', 'a' ) // error
),
$pipes // respective outputs
);
fclose( $pipes[0] );
var_dump( stream_get_contents( $pipes[1] ) );
fclose( $pipes[1] );
proc_close($process);
</source>
popen seems to work in either case. proc_open() also works without the quotes:
<pre>
Aaron@AARON-PC-GAME /c/wamp/www/MW_trunk
$ php shelltest.php
string(162) "Total views : 654
Total edits : 194712
Number of articles: 4900
Total pages : 16430
Number of users : 8
Number of images : 46
"
</pre>
However, proc_open() gives an empty response when I have the extra quotes
<pre>
Aaron@AARON-PC-GAME /c/wamp/www/MW_trunk
$ php shelltest.php
string(0) ""
</pre>
_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview