From 46c5e055a291923634bc2ec61fe62ca06c610bc4 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Tue, 26 May 2015 14:28:07 -0700 Subject: [PATCH] All day events should obey selected query range in viewer timezone. Summary: Fixes T8147, All day events should obey selected query range in viewer timezone. Test Plan: Create all day event May 25, query for events May 26-27. All day event should not be part of the query results list. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T8147 Differential Revision: https://secure.phabricator.com/D13023 --- .../query/PhabricatorCalendarEventQuery.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php index 474ac49a46..bdc87aaf26 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php @@ -180,6 +180,21 @@ final class PhabricatorCalendarEventQuery protected function willFilterPage(array $events) { + $range_start = $this->rangeBegin; + $range_end = $this->rangeEnd; + + foreach ($events as $key => $event) { + $event_start = $event->getDateFrom(); + $event_end = $event->getDateTo(); + + if ($range_start && $event_end < $range_start) { + unset($events[$key]); + } + if ($range_end && $event_start > $range_end) { + unset($events[$key]); + } + } + $phids = array(); foreach ($events as $event) { @@ -197,6 +212,8 @@ final class PhabricatorCalendarEventQuery $event->attachInvitees($event_invitees); } + $events = msort($events, 'getDateFrom'); + return $events; }