diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-02-17 08:52:26 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-02-17 08:52:26 +0400 |
commit | c81846e19442c227e4a6576491cdebf92a3bb57f (patch) | |
tree | 4f42c1e0d7979c54f7d548936742f723829a2da5 /core | |
parent | b391e7313a5c987299e1a82a1827a81c1add56f1 (diff) |
Fixing bug where pre-processed segment would not be fully pre-process.
Diffstat (limited to 'core')
-rw-r--r-- | core/Archive.php | 4 | ||||
-rw-r--r-- | core/ArchiveProcessor/Loader.php | 2 | ||||
-rw-r--r-- | core/ArchiveProcessor/PluginsArchiver.php | 1 | ||||
-rw-r--r-- | core/ArchiveProcessor/Rules.php | 32 | ||||
-rw-r--r-- | core/DataAccess/ArchiveWriter.php | 3 |
5 files changed, 31 insertions, 11 deletions
diff --git a/core/Archive.php b/core/Archive.php index 18e4243268..db1ca62ded 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -545,7 +545,7 @@ class Archive // cache id archives for plugins we haven't processed yet if (!empty($archiveGroups)) { - if (!Rules::isArchivingDisabledFor($this->params->getSegment(), $this->getPeriodLabel())) { + if (!Rules::isArchivingDisabledFor($this->params->getIdSites(), $this->params->getSegment(), $this->getPeriodLabel())) { $this->cacheArchiveIdsAfterLaunching($archiveGroups, $plugins); } else { @@ -644,7 +644,7 @@ class Archive */ private function getDoneStringForPlugin($plugin) { - return Rules::getDoneStringFlagFor($this->params->getSegment(), $this->getPeriodLabel(), $plugin); + return Rules::getDoneStringFlagFor($this->params->getIdSites(), $this->params->getSegment(), $this->getPeriodLabel(), $plugin); } private function getPeriodLabel() diff --git a/core/ArchiveProcessor/Loader.php b/core/ArchiveProcessor/Loader.php index c37fd2e934..b3ac4cd3f4 100644 --- a/core/ArchiveProcessor/Loader.php +++ b/core/ArchiveProcessor/Loader.php @@ -129,7 +129,7 @@ class Loader protected function doesRequestedPluginIncludeVisitsSummary() { $processAllReportsIncludingVisitsSummary = - Rules::shouldProcessReportsAllPlugins($this->params->getSegment(), $this->params->getPeriod()->getLabel()); + Rules::shouldProcessReportsAllPlugins($this->params->getIdSites(), $this->params->getSegment(), $this->params->getPeriod()->getLabel()); $doesRequestedPluginIncludeVisitsSummary = $processAllReportsIncludingVisitsSummary || $this->params->getRequestedPlugin() == 'VisitsSummary'; return $doesRequestedPluginIncludeVisitsSummary; diff --git a/core/ArchiveProcessor/PluginsArchiver.php b/core/ArchiveProcessor/PluginsArchiver.php index e98cab0a3e..6e16affcb2 100644 --- a/core/ArchiveProcessor/PluginsArchiver.php +++ b/core/ArchiveProcessor/PluginsArchiver.php @@ -152,6 +152,7 @@ class PluginsArchiver return true; } if (Rules::shouldProcessReportsAllPlugins( + $this->params->getIdSites(), $this->params->getSegment(), $this->params->getPeriod()->getLabel())) { return true; diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php index b6a253f669..6ac43ddc06 100644 --- a/core/ArchiveProcessor/Rules.php +++ b/core/ArchiveProcessor/Rules.php @@ -50,21 +50,21 @@ class Rules * @param string $plugin * @return string */ - public static function getDoneStringFlagFor($segment, $periodLabel, $plugin) + public static function getDoneStringFlagFor(array $idSites, $segment, $periodLabel, $plugin) { - if (!self::shouldProcessReportsAllPlugins($segment, $periodLabel)) { + if (!self::shouldProcessReportsAllPlugins($idSites, $segment, $periodLabel)) { return self::getDoneFlagArchiveContainsOnePlugin($segment, $plugin); } return self::getDoneFlagArchiveContainsAllPlugins($segment); } - public static function shouldProcessReportsAllPlugins(Segment $segment, $periodLabel) + public static function shouldProcessReportsAllPlugins(array $idSites, Segment $segment, $periodLabel) { if ($segment->isEmpty() && $periodLabel != 'range') { return true; } - $segmentsToProcess = SettingsPiwik::getKnownSegmentsToArchive(); + $segmentsToProcess = self::getSegmentsToProcess($idSites); if (!empty($segmentsToProcess)) { // If the requested segment is one of the segments to pre-process // we ensure that any call to the API will trigger archiving of all reports for this segment @@ -76,6 +76,23 @@ class Rules return false; } + /** + * @param $idSites + * @return array + */ + private static function getSegmentsToProcess($idSites) + { + $knownSegmentsToArchiveAllSites = SettingsPiwik::getKnownSegmentsToArchive(); + + $segmentsToProcess = $knownSegmentsToArchiveAllSites; + foreach ($idSites as $idSite) { + $segmentForThisWebsite = SettingsPiwik::getKnownSegmentsToArchiveForSite($idSite); + $segmentsToProcess = array_merge($segmentsToProcess, $segmentForThisWebsite); + } + $segmentsToProcess = array_unique($segmentsToProcess); + return $segmentsToProcess; + } + private static function getDoneFlagArchiveContainsOnePlugin(Segment $segment, $plugin) { return 'done' . $segment->getHash() . '.' . $plugin; @@ -155,7 +172,8 @@ class Rules $now = time(); $minimumArchiveTime = $now - Rules::getTodayArchiveTimeToLive(); - $isArchivingDisabled = Rules::isArchivingDisabledFor($segment, $period->getLabel()); + $idSites = array($site->getId()); + $isArchivingDisabled = Rules::isArchivingDisabledFor($idSites, $segment, $period->getLabel()); if ($isArchivingDisabled) { if ($period->getNumberOfSubperiods() == 0 && $dateStart->getTimestamp() <= $now @@ -194,12 +212,12 @@ class Rules return Config::getInstance()->General['time_before_today_archive_considered_outdated']; } - public static function isArchivingDisabledFor(Segment $segment, $periodLabel) + public static function isArchivingDisabledFor(array $idSites, Segment $segment, $periodLabel) { if ($periodLabel == 'range') { return false; } - $processOneReportOnly = !self::shouldProcessReportsAllPlugins($segment, $periodLabel); + $processOneReportOnly = !self::shouldProcessReportsAllPlugins($idSites, $segment, $periodLabel); $isArchivingDisabled = !self::isRequestAuthorizedToArchive(); if ($processOneReportOnly) { diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php index 576de79b84..bd11053089 100644 --- a/core/DataAccess/ArchiveWriter.php +++ b/core/DataAccess/ArchiveWriter.php @@ -65,7 +65,8 @@ class ArchiveWriter $this->idSite = $params->getSite()->getId(); $this->segment = $params->getSegment(); $this->period = $params->getPeriod(); - $this->doneFlag = Rules::getDoneStringFlagFor($this->segment, $this->period->getLabel(), $params->getRequestedPlugin()); + $idSites = array($this->idSite); + $this->doneFlag = Rules::getDoneStringFlagFor($idSites, $this->segment, $this->period->getLabel(), $params->getRequestedPlugin()); $this->isArchiveTemporary = $isArchiveTemporary; $this->dateStart = $this->period->getDateStart(); |