diff options
author | diosmosis <benaka@piwik.pro> | 2015-09-20 08:19:17 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-10-12 21:05:35 +0300 |
commit | 13e9db553be041ee9b072ab0e7186c30cee0595f (patch) | |
tree | c50c262409ac6e0d27dfe6845288605ebac03767 /core/Archive.php | |
parent | f6f444ec6a9a2af341812d460c97c189cb5ee04e (diff) |
Make ArchiveInvalidator an immutable service and add it to DI. markArchivesAsInvalidated (or whatever it's called) now returns an instance instead of an array of output messages.
Diffstat (limited to 'core/Archive.php')
-rw-r--r-- | core/Archive.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/core/Archive.php b/core/Archive.php index 5413393972..80ef151f38 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -11,6 +11,7 @@ namespace Piwik; use Piwik\Archive\Parameters; use Piwik\ArchiveProcessor\Rules; use Piwik\Archive\ArchiveInvalidator; +use Piwik\Container\StaticContainer; use Piwik\DataAccess\ArchiveSelector; use Piwik\Period\Factory as PeriodFactory; @@ -167,6 +168,11 @@ class Archive private static $cache; /** + * @var ArchiveInvalidator + */ + private $invalidator; + + /** * @param Parameters $params * @param bool $forceIndexedBySite Whether to force index the result of a query by site ID. * @param bool $forceIndexedByDate Whether to force index the result of a query by period. @@ -177,6 +183,8 @@ class Archive $this->params = $params; $this->forceIndexedBySite = $forceIndexedBySite; $this->forceIndexedByDate = $forceIndexedByDate; + + $this->invalidator = StaticContainer::get('Piwik\Archive\ArchiveInvalidator'); } /** @@ -539,8 +547,7 @@ class Archive return; // all requested site ids were already handled } - $invalidator = new ArchiveInvalidator(); - $sitesPerDays = $invalidator->getRememberedArchivedReportsThatShouldBeInvalidated(); + $sitesPerDays = $this->invalidator->getRememberedArchivedReportsThatShouldBeInvalidated(); foreach ($sitesPerDays as $date => $siteIds) { if (empty($siteIds)) { @@ -554,7 +561,7 @@ class Archive } try { - $invalidator->markArchivesAsInvalidated($siteIdsToActuallyInvalidate, array(Date::factory($date)), false); + $this->invalidator->markArchivesAsInvalidated($siteIdsToActuallyInvalidate, array(Date::factory($date)), false); } catch (\Exception $e) { Site::clearCache(); throw $e; |