diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-06-13 07:09:33 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-06-13 07:09:33 +0400 |
commit | e27243355ecae1ec449995a2c86ab0f836df1822 (patch) | |
tree | 51503bc76447589f1b6d6abbf2590b8fd957483a /core/CliMulti.php | |
parent | ae2441f24e613a47c7711582a3ad00072f157578 (diff) |
Fixes #5343 Cron core:archive: make sure the PHP cli binary is at least 5.3.2
Diffstat (limited to 'core/CliMulti.php')
-rw-r--r-- | core/CliMulti.php | 57 |
1 files changed, 9 insertions, 48 deletions
diff --git a/core/CliMulti.php b/core/CliMulti.php index af576f685d..8085631feb 100644 --- a/core/CliMulti.php +++ b/core/CliMulti.php @@ -7,6 +7,7 @@ */ namespace Piwik; +use Piwik\CliMulti\CliPhp; use Piwik\CliMulti\Output; use Piwik\CliMulti\Process; @@ -157,11 +158,17 @@ class CliMulti { * What is missing under windows? Detection whether a process is still running in Process::isProcessStillRunning * and how to send a process into background in start() */ - private function supportsAsync() + public function supportsAsync() { return Process::isSupported() && $this->findPhpBinary(); } + private function findPhpBinary() + { + $cliPhp = new CliPhp(); + return $cliPhp->findPhpBinary(); + } + private function cleanup() { foreach ($this->processes as $pid) { @@ -204,36 +211,6 @@ class CliMulti { return SettingsPiwik::rewriteTmpPathWithInstanceId($dir); } - private function findPhpBinary() - { - if (defined('PHP_BINARY') && $this->isValidPhpType(PHP_BINARY)) { - return PHP_BINARY; - } - - $bin = ''; - - if (!empty($_SERVER['_']) && Common::isPhpCliMode()) { - $bin = $this->getPhpCommandIfValid($_SERVER['_']); - } - - if (empty($bin) && !empty($_SERVER['argv'][0]) && Common::isPhpCliMode()) { - $bin = $this->getPhpCommandIfValid($_SERVER['argv'][0]); - } - - if (!$this->isValidPhpType($bin)) { - $bin = shell_exec('which php'); - } - - if (!$this->isValidPhpType($bin)) { - $bin = shell_exec('which php5'); - } - - if ($this->isValidPhpType($bin)) { - return trim($bin); - } - - return false; - } private function executeAsyncCli($url, Output $output, $cmdId) { @@ -280,23 +257,6 @@ class CliMulti { return $url; } - private function isValidPhpType($path) - { - return !empty($path) - && false === strpos($path, 'fpm') - && false === strpos($path, 'cgi') - && false === strpos($path, 'phpunit'); - } - - private function getPhpCommandIfValid($path) - { - if (!empty($path) && is_executable($path)) { - if (0 === strpos($path, PHP_BINDIR) && $this->isValidPhpType($path)) { - return $path; - } - } - } - /** * @param array $piwikUrls * @return array @@ -316,4 +276,5 @@ class CliMulti { return $results; } + } |