Replace wfShellExec() with a class
authorMax Semenik <maxsem.wiki@gmail.com>
Thu, 3 Nov 2016 00:27:15 +0000 (17:27 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Sat, 9 Sep 2017 04:49:49 +0000 (21:49 -0700)
commit77ce3b98a0193b674232e972e7c6993a585412d7
tree394dbc0788977649fd62b3cc976ea1209220aed0
parent104d86442554b466c282834c780eed3580a146d7
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
RELEASE-NOTES-1.30
autoload.php
includes/GlobalFunctions.php
includes/exception/ProcOpenError.php [new file with mode: 0644]
includes/exception/ShellDisabledError.php [new file with mode: 0644]
includes/shell/Command.php [new file with mode: 0644]
includes/shell/Result.php [new file with mode: 0644]
includes/shell/Shell.php [new file with mode: 0644]
tests/phpunit/includes/shell/CommandTest.php [new file with mode: 0644]
tests/phpunit/includes/shell/ShellTest.php [new file with mode: 0644]