From 0cd0888be9fbf351a9e76cd4367cde1e715f1c10 Mon Sep 17 00:00:00 2001 From: vagrant Date: Thu, 30 Jan 2014 20:00:08 +0000 Subject: [PATCH] refs #4532 easier fix with less logic --- core/DataAccess/ArchiveSelector.php | 31 ++++++----------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/core/DataAccess/ArchiveSelector.php b/core/DataAccess/ArchiveSelector.php index b39829895ba..3f34ad8c935 100644 --- a/core/DataAccess/ArchiveSelector.php +++ b/core/DataAccess/ArchiveSelector.php @@ -177,39 +177,20 @@ static public function getArchiveIds($siteIds, $periods, $segment, $plugins) $bind[] = $firstPeriod->getDateEnd()->toString('Y-m-d'); } else { // we assume there is no range date in $periods - $dateStrs = array(); - $dayPeriod = null; $dateCondition = '('; foreach ($periods as $period) { - if ($period instanceof Period\Day) { - $dateStrs[] = $period->getDateStart()->toString('Y-m-d'); - $dayPeriod = $period; + if (strlen($dateCondition) > 1) { + $dateCondition .= ' OR '; } - } - - if (!empty($dayPeriod) && !empty($dateStrs)) { - $bind[] = $dayPeriod->getId(); - $dateCondition .= "(period = ? AND date1 IN ('" . implode("','", $dateStrs) . "'))"; - } - - reset($periods); - foreach ($periods as $period) { - if ($period instanceof Period\Week || $period instanceof Period\Month || $period instanceof Period\Year) { - - if (strlen($dateCondition) > 5) { - $dateCondition .= ' OR '; - } - $dateCondition .= "(period = ? AND date1 = ? AND date2 = ?)"; - $bind[] = $period->getId(); - $bind[] = $period->getDateStart()->toString('Y-m-d'); - $bind[] = $period->getDateEnd()->toString('Y-m-d'); - } + $dateCondition .= "(period = ? AND date1 = ? AND date2 = ?)"; + $bind[] = $period->getId(); + $bind[] = $period->getDateStart()->toString('Y-m-d'); + $bind[] = $period->getDateEnd()->toString('Y-m-d'); } $dateCondition .= ')'; - } $sql = sprintf($getArchiveIdsSql, $table, $dateCondition);