Commit graph

5 commits

Author SHA1 Message Date
jenkins-bot
d4f712c326 Merge "Suppress error in MediaWiki\Shell\Command" 2017-10-10 18:52:53 +00:00
Gergő Tisza
2ebb0ca271 Suppress error in MediaWiki\Shell\Command
Command uses a certain error message to detect and ignore
EINTR in stream_select, and uses trigger_error to clear
the message from get_last_error (clear_last_error is PHP7 only).
This works rather poorly with a system config that does not catch
or ignore most errors; specifically it breaks database tests
on Vagrant with the warnings_as_errors role on.

Change-Id: I9c8f922bc0a8f5ee6b8e7501b22223cce4f98ecb
2017-10-09 00:28:02 +00:00
Max Semenik
7c3d3d54bd Get rid of $IP in Command
Change-Id: Iccfe1b79963462f9cad80ff327ccd574ee1122c5
2017-10-06 19:50:45 -07:00
Max Semenik
1bb9a223d2 Inject dependencies into Shell\Command
This slightly changes how execution time limits fall back on each other.

Change-Id: I7754a9e6be9638eebe90cb953adb8e2a6ee97cef
2017-10-03 20:01:59 -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