diff --git a/core/Archive.php b/core/Archive.php index 18e424326816aaffcfb1f22b02c70f2994186e33..db1ca62ded6458cffc95f40b5787a119d29a7965 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 c37fd2e934203040e007aa4e55265fa9b7f98025..b3ac4cd3f49459f5f27242d6d60f4305185aa019 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 e98cab0a3e153356ee0ae56f40c609c38a1f138d..6e16affcb2e0658147e23e44a58043ddd21f3c02 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 b6a253f669bd78f36b113df8f826fe27f4c17072..6ac43ddc06955852d91858d8071bb495d8d1ffa2 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 576de79b843173d63ac3c5fcbef9eea850697b12..bd11053089ab9c95f515c140d14d6a26bfd15375 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();