diff options
author | diosmosis <benaka@piwik.pro> | 2015-10-08 03:32:08 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-10-12 21:05:37 +0300 |
commit | c186252bf9a30a54c15330f0f4c88c1a033e7f25 (patch) | |
tree | d3c288649d36b242844129a1aea8fb3ec3488a12 /core/DataAccess | |
parent | b588b2bce30e0da5283eea0d5b1830e6fe8bf761 (diff) |
Fix regression, make sure if period is not supplied to ArchiveInvalidator then all periods are invalidated efficiently.
Diffstat (limited to 'core/DataAccess')
-rw-r--r-- | core/DataAccess/Model.php | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/core/DataAccess/Model.php b/core/DataAccess/Model.php index f70a934d13..e8ec27c7de 100644 --- a/core/DataAccess/Model.php +++ b/core/DataAccess/Model.php @@ -100,28 +100,33 @@ class Model /** * @param string $archiveTable Prefixed table name * @param int[] $idSites - * @param Period[][] $periodsByType + * @param string[][] $datesByPeriodType * @param Segment $segment * @return \Zend_Db_Statement * @throws Exception */ - public function updateArchiveAsInvalidated($archiveTable, $idSites, $periodsByType, Segment $segment = null) + public function updateArchiveAsInvalidated($archiveTable, $idSites, $datesByPeriodType, Segment $segment = null) { $idSites = array_map('intval', $idSites); $bind = array(); $periodConditions = array(); - foreach ($periodsByType as $periodType => $periods) { + foreach ($datesByPeriodType as $periodType => $dates) { $dateConditions = array(); - foreach ($periods as $period) { + foreach ($dates as $date) { $dateConditions[] = "(date1 <= ? AND ? <= date2)"; - $bind[] = $period->getDateStart()->toString(); - $bind[] = $period->getDateStart()->toString(); + $bind[] = $date; + $bind[] = $date; } - $periodConditions[] = "(period = " . (int)$periodType . " AND (" . implode(" OR ", $dateConditions) . "))"; + $dateConditionsSql = implode(" OR ", $dateConditions); + if (empty($periodType)) { // remove all periods + $periodConditions[] = "($dateConditionsSql)"; + } else { + $periodConditions[] = "(period = " . (int)$periodType . " AND ($dateConditionsSql))"; + } } if ($segment) { |