From: Kunal Mehta Date: Sun, 24 Jun 2018 21:09:32 +0000 (+0300) Subject: shell: Note that ::isDisabled() should be called before ::command() X-Git-Tag: 1.34.0-rc.0~4892 X-Git-Url: https://git.cyclocoop.org/admin/%7B%24admin_url%7Dmembres/import.php?a=commitdiff_plain;h=83524ae39afc953f33724ffd5ea35ac72ccd6134;p=lhc%2Fweb%2Fwiklou.git shell: Note that ::isDisabled() should be called before ::command() And check it in the FirejailCommandTest (integration) for completeness, even though it will make no practical difference. Change-Id: Ieb130a888ef8a8162cb0a049ab9c20eac3f58217 --- diff --git a/includes/shell/Shell.php b/includes/shell/Shell.php index ee9f1ebbf7..0ddc443f31 100644 --- a/includes/shell/Shell.php +++ b/includes/shell/Shell.php @@ -110,6 +110,7 @@ class Shell { /** * Returns a new instance of Command class * + * @note You should check Shell::isDisabled() before calling this * @param string|string[] ...$commands String or array of strings representing the command to * be executed, each value will be escaped. * Example: [ 'convert', '-font', 'font name' ] would produce "'convert' '-font' 'font name'" @@ -223,6 +224,7 @@ class Shell { * Note that $parameters should be a flat array and an option with an argument * should consist of two consecutive items in the array (do not use "--option value"). * + * @note You should check Shell::isDisabled() before calling this * @param string $script MediaWiki CLI script with full path * @param string[] $parameters Arguments and options to the script * @param array $options Associative array of options: diff --git a/tests/integration/includes/shell/FirejailCommandTest.php b/tests/integration/includes/shell/FirejailCommandTest.php index 1e008ee279..47300051a1 100644 --- a/tests/integration/includes/shell/FirejailCommandTest.php +++ b/tests/integration/includes/shell/FirejailCommandTest.php @@ -16,7 +16,9 @@ class FirejailCommandIntegrationTest extends PHPUnit\Framework\TestCase { public function setUp() { parent::setUp(); - if ( Shell::command( 'which', 'firejail' )->execute()->getExitCode() ) { + if ( Shell::isDisabled() ) { + $this->markTestSkipped( 'shelling out is disabled' ); + } elseif ( Shell::command( 'which', 'firejail' )->execute()->getExitCode() ) { $this->markTestSkipped( 'firejail not installed' ); } elseif ( wfIsWindows() ) { $this->markTestSkipped( 'test supports POSIX environments only' );