diff options
author | diosmosis <benaka@piwik.pro> | 2015-09-25 05:19:13 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-09-25 06:02:52 +0300 |
commit | d5226a0bdb29e8ebf3c7589bbf9df3593914eb69 (patch) | |
tree | 67443031ca7847a070fd57a3c5043c6c84e4e7cf /plugins/SitesManager/Tracker | |
parent | cf76baf0cc813aecce29bbfa988ffd206ac63107 (diff) |
Replicate old logic in ArchiveInvalidator to the letter to get some tests to pass.
Diffstat (limited to 'plugins/SitesManager/Tracker')
-rw-r--r-- | plugins/SitesManager/Tracker/SitesManagerRequestProcessor.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/plugins/SitesManager/Tracker/SitesManagerRequestProcessor.php b/plugins/SitesManager/Tracker/SitesManagerRequestProcessor.php index 0f509172e8..59357e0195 100644 --- a/plugins/SitesManager/Tracker/SitesManagerRequestProcessor.php +++ b/plugins/SitesManager/Tracker/SitesManagerRequestProcessor.php @@ -42,8 +42,18 @@ class SitesManagerRequestProcessor extends RequestProcessor $idSite = $request->getIdSite(); $createdTimeTimestamp = $this->getSiteCreatedTime($idSite); - if ($request->getCurrentTimestamp() < $createdTimeTimestamp) { - $this->updateSiteCreatedTime($idSite, $request->getCurrentTimestamp()); + $requestTimestamp = Date::factory($request->getCurrentTimestamp()); + + // replicating old Piwik logic, see: + // https://github.com/piwik/piwik/blob/baa6da86266c7c44bc2d65821c7ffe042c2f4716/core/Archive/ArchiveInvalidator.php#L150 + // before when this was done during archive invalidation, the date would not have an attached time and + // one extra day was subtracted from the minimum. + // I am not sure why this is required or if it is still required, but some tests that check the contents + // of archive tables will fail w/o this. + $requestTimestamp = $requestTimestamp->subDay(1)->setTime('00:00:00'); + + if ($requestTimestamp->isEarlier($createdTimeTimestamp)) { + $this->updateSiteCreatedTime($idSite, $requestTimestamp); } } @@ -51,12 +61,12 @@ class SitesManagerRequestProcessor extends RequestProcessor { $attributes = Cache::getCacheWebsiteAttributes($idSite); $tsCreated = isset($attributes['ts_created']) ? $attributes['ts_created'] : 0; - return Date::factory($tsCreated)->getTimestamp(); + return Date::factory($tsCreated); } - private function updateSiteCreatedTime($idSite, $timestamp) + private function updateSiteCreatedTime($idSite, Date $timestamp) { - $this->sitesManagerModel->updateSiteCreatedTime(array($idSite), Date::factory($timestamp)->getDatetime()); + $this->sitesManagerModel->updateSiteCreatedTime(array($idSite), $timestamp->getDatetime()); Cache::deleteCacheWebsiteAttributes($idSite); } }
\ No newline at end of file |