Permalink
Browse files

Fixes #4824 Use HTTP API instead of async CLI when shell_exec is disa…

…bled
  • Loading branch information...
1 parent 47cc9a2 commit 360ca4024f9b44e27cbb182801ce7b6040dbdece @mattab mattab committed Mar 7, 2014
Showing with 14 additions and 1 deletion.
  1. +4 −1 core/CliMulti.php
  2. +10 −0 core/CliMulti/Process.php
View
5 core/CliMulti.php
@@ -148,7 +148,9 @@ private function generateCommandId($command)
*/
private function supportsAsync()
{
- return !SettingsServer::isWindows() && Process::isSupported() && $this->findPhpBinary();
+ return !SettingsServer::isWindows()
+ && Process::isSupported()
+ && $this->findPhpBinary();
}
private function cleanup()
@@ -233,6 +235,7 @@ private function executeAsyncCli($url, Output $output, $cmdId)
private function executeNotAsyncHttp($url, Output $output)
{
try {
+ Log::debug("Execute HTTP API request: " . $url);
$response = Http::sendHttpRequestBy('curl', $url, $timeout = 0, $userAgent = null, $destinationPath = null, $file = null, $followDepth = 0, $acceptLanguage = false, $this->acceptInvalidSSLCertificate);
$output->write($response);
} catch (\Exception $e) {
View
10 core/CliMulti/Process.php
@@ -146,13 +146,23 @@ public static function isSupported()
return false;
}
+ if(!self::shellExecFunctionExists()) {
+ return false;
+ }
if (static::commandExists('ps') && self::returnsSuccessCode('ps') && self::commandExists('awk')) {
return true;
}
return false;
}
+ private static function shellExecFunctionExists()
+ {
+ $command = 'pcntl_signal_dispatch';
+ $disabled = explode(',', ini_get('disable_functions'));
+ return !in_array($command, $disabled);
+ }
+
private static function returnsSuccessCode($command)
{
$exec = $command . ' > /dev/null 2>&1 & echo $?';

0 comments on commit 360ca40

Please sign in to comment.