Commit graph

4 commits

Author SHA1 Message Date
Gergő Tisza
7d9dbc0040
MediaWiki\Shell: log stderr
Change-Id: I1495fe2aba10102d7e36c3a3e5fdabf97f14546b
2017-10-26 21:06:03 -07:00
Max Semenik
4d9a95f970 Don't trigger PHP errors for unused Shell\Command
Change-Id: Id29da4f21a44ccb18d8a2ae11348d69ca3233aa5
2017-10-17 18:55:11 -07:00
Max Semenik
926c97c69f
Return stderr from Shell\Command
Change-Id: I5551ae4bbe7b539b528a734aa82198b11f103871
2017-10-12 02:12:20 -07:00
Max Semenik
77ce3b98a0 Replace wfShellExec() with a class
This function has gotten so unwieldy that a helper was
introduced. Instead, here's this class that makes
shelling out easier and more readable.

Example usage:
  $result = Shell::command( 'shell command' )
       ->environment( [ 'ENVIRONMENT_VARIABLE' => 'VALUE' ] )
       ->limits( [ 'time' => 300 ] )
       ->execute();

  $exitCode = $result->getExitCode();
  $output = $result->getStdout();

This is a minimal change, so lots of stuff remains
unrefactored - I'd rather limit the scope of this commit.
A future improvement could be an ability to get stderr
separately from stdout.

Caveat: execution errors (proc_open is disabled/returned error) now
throw errors instead of returning a status code. wfShellExec() still
emulates this behavior though.

Competing commit: I7dccb2b67a4173a8a89b035e444fbda9102e4d0f
<legoktm> MaxSem: so you should continue working on your patch and I'll
          probably refactor on top of it later after its merged :P

Change-Id: I8ac9858b80d7908cf7e7981d7e19d0fc9c2265c0
2017-09-08 21:49:49 -07:00