Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-02-11 06:48:01 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-02-11 06:48:01 +0400
commit6247a101b9cd8b8f389b1188844ac63f670a5780 (patch)
treef1e8eca6f585894ace9d677c107ce53dc8d1e27e /core/CliMulti.php
parentfdc866ab9aac1dccd0ed1e5009537738c5a9ae19 (diff)
refs #4610 store everything in climulti folder for easier cleanup later, some other optimizations
Diffstat (limited to 'core/CliMulti.php')
-rw-r--r--core/CliMulti.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/CliMulti.php b/core/CliMulti.php
index 9948ce1f7d..e500ac8a82 100644
--- a/core/CliMulti.php
+++ b/core/CliMulti.php
@@ -55,17 +55,17 @@ class CliMulti {
private function start($piwikUrls)
{
foreach ($piwikUrls as $index => $url) {
- $cmdId = $this->generateCmdId($url);
+ $cmdId = $this->generateCommandId($url);
$pid = $cmdId . $index . '_cli_multi_pid';
$outputId = $cmdId . $index . '_cli_multi_output';
$this->processes[] = new Process($pid);
$this->outputs[] = new Output($outputId);
- $command = $this->buildCommand($url, array('outputId' => $outputId, 'pid' => $pid));
- $appendix = $this->supportsAsync() ? ' > /dev/null 2>&1 &' : '';
+ $query = $this->getQueryFromUrl($url, array('outputId' => $outputId, 'pid' => $pid));
+ $command = $this->buildCommand($query);
- shell_exec($command . $appendix);
+ shell_exec($command);
if (!$this->supportsAsync()) {
end($this->processes)->finishProcess();
@@ -73,7 +73,7 @@ class CliMulti {
}
}
- private function buildCommand($aUrl, $additionalParams = array())
+ private function getQueryFromUrl($aUrl, array $additionalParams)
{
$url = @parse_url($aUrl);
$query = '';
@@ -86,12 +86,18 @@ class CliMulti {
if (!empty($query)) {
$query .= '&';
}
+
$query .= http_build_query($additionalParams);
}
- $command = PIWIK_INCLUDE_PATH . '/console climulti:request ' . escapeshellarg($query);
+ return $query;
+ }
+
+ private function buildCommand($query)
+ {
+ $appendix = $this->supportsAsync() ? ' > /dev/null 2>&1 &' : '';
- return $command;
+ return PIWIK_INCLUDE_PATH . '/console climulti:request ' . escapeshellarg($query) . $appendix;
}
private function getResponse()
@@ -120,7 +126,7 @@ class CliMulti {
return true;
}
- private function generateCmdId($command)
+ private function generateCommandId($command)
{
return md5($command . microtime(true) . rand(0, 99999));
}