diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-08 06:42:20 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-08 06:42:20 +0400 |
commit | ffce42a1234000be1fb3fcaf33918da38b8af374 (patch) | |
tree | bb9c2efcf314b893c3ffbb2dd350cee7d5803866 /core/ArchiveProcessor | |
parent | 8d5b6095ecebe90b6dc33e2a798c07b33d46a0b3 (diff) |
Refs #4278 I broke the build, don't know why yet
Diffstat (limited to 'core/ArchiveProcessor')
-rw-r--r-- | core/ArchiveProcessor/Loader.php | 23 | ||||
-rw-r--r-- | core/ArchiveProcessor/PluginsArchiver.php | 10 |
2 files changed, 20 insertions, 13 deletions
diff --git a/core/ArchiveProcessor/Loader.php b/core/ArchiveProcessor/Loader.php index 530f66eb61..724dac5da0 100644 --- a/core/ArchiveProcessor/Loader.php +++ b/core/ArchiveProcessor/Loader.php @@ -57,9 +57,9 @@ class Loader /** * @return bool */ - protected function isVisitsCountAlreadyProcessed($visits) + protected function mustProcessVisitCount($visits) { - return $visits !== false; + return $visits === false; } public function prepareArchive() @@ -87,19 +87,25 @@ class Loader { $createSeparateArchiveForCoreMetrics = !$this->doesRequestedPluginIncludeVisitsSummary() - && !$this->isVisitsCountAlreadyProcessed($visits); + && $this->mustProcessVisitCount($visits); if ($createSeparateArchiveForCoreMetrics) { $requestedPlugin = $this->params->getRequestedPlugin(); $this->params->setRequestedPlugin('VisitsSummary'); - $this->computeNewArchive($enforceProcessCoreMetricsOnly = true, $visits); + list($idArchive, $visits) = $this->computeNewArchive($enforceProcessCoreMetricsOnly = true); $this->params->setRequestedPlugin($requestedPlugin); + + if($this->mustProcessVisitCount($visits)) { + throw new \Exception("Visit count should have been set in computeNewArchive()."); + } } + return $visits; } - protected function computeNewArchive($enforceProcessCoreMetricsOnly, $visits) + protected function computeNewArchive($enforceProcessCoreMetricsOnly, $visits = false) { - $archiveWriter = new ArchiveWriter($this->params->getSite()->getId(), $this->params->getSegment(), $this->params->getPeriod(), $this->params->getRequestedPlugin(), $this->isArchiveTemporary()); + $archiveWriter = new ArchiveWriter($this->params, $this->isArchiveTemporary()); + $archiveWriter->initNewArchive(); $pluginsArchiver = new PluginsArchiver($archiveWriter, $this->params); @@ -107,7 +113,7 @@ class Loader if($enforceProcessCoreMetricsOnly) { $visits = $pluginsArchiver->callAggregateCoreMetrics(); } else { - if (!$this->isVisitsCountAlreadyProcessed($visits) + if ($this->mustProcessVisitCount($visits) || $this->doesRequestedPluginIncludeVisitsSummary() ) { $visits = $pluginsArchiver->callAggregateCoreMetrics(); @@ -167,7 +173,8 @@ class Loader if (!$idAndVisits) { return array(false, false); } - return $idAndVisits; + list($idArchive, $visits, $visitsConverted) = $idAndVisits; + return array($idArchive, $visits); } /** diff --git a/core/ArchiveProcessor/PluginsArchiver.php b/core/ArchiveProcessor/PluginsArchiver.php index cc80021142..16dcb2afb0 100644 --- a/core/ArchiveProcessor/PluginsArchiver.php +++ b/core/ArchiveProcessor/PluginsArchiver.php @@ -58,6 +58,7 @@ class PluginsArchiver $metrics = $this->aggregateMultipleVisitsMetrics(); } + $visits = false; if (!empty($metrics)) { $this->archiveProcessor->setNumberOfVisits($metrics['nb_visits'], $metrics['nb_visits_converted']); $visits = $metrics['nb_visits']; @@ -72,7 +73,6 @@ class PluginsArchiver */ public function callAggregateAllPlugins() { - $pluginBeingProcessed = $this->archiveProcessor->getParams()->getRequestedPlugin(); $isAggregateForDay = $this->archiveProcessor->getParams()->isDayArchive(); $archivers = $this->getPluginArchivers(); @@ -80,7 +80,7 @@ class PluginsArchiver /** @var Archiver $archiver */ $archiver = new $archiverClass($this->archiveProcessor); - if($this->shouldProcessReportsForPlugin($pluginBeingProcessed, $pluginName)) { + if($this->shouldProcessReportsForPlugin($pluginName)) { if($isAggregateForDay) { $archiver->aggregateDayReport(); } else { @@ -123,10 +123,10 @@ class PluginsArchiver * @param string $pluginName * @return bool */ - protected function shouldProcessReportsForPlugin($pluginBeingProcessed, $pluginName) + protected function shouldProcessReportsForPlugin($pluginName) { // If any other segment, only process if the requested report belong to this plugin - if ($pluginBeingProcessed == $pluginName) { + if ($this->params->getRequestedPlugin() == $pluginName) { return true; } if (Rules::shouldProcessReportsAllPlugins( @@ -134,7 +134,7 @@ class PluginsArchiver $this->archiveProcessor->getParams()->getPeriod()->getLabel())) { return true; } - if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded($pluginBeingProcessed)) { + if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded($this->params->getRequestedPlugin())) { return true; } return false; |