Page MenuHomePhabricator

D13354.diff
No OneTemporary

D13354.diff

diff --git a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php
--- a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php
+++ b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php
@@ -14,6 +14,12 @@
private $instanceSequencePairs;
private $generateGhosts = false;
+ private $skipApplyTimezone = false;
+
+ public function setSkipApplyTimezone($skip_apply_timezone) {
+ $this->skipApplyTimezone = $skip_apply_timezone;
+ return $this;
+ }
public function setGenerateGhosts($generate_ghosts) {
$this->generateGhosts = $generate_ghosts;
@@ -102,8 +108,10 @@
$events = $table->loadAllFromArray($data);
- foreach ($events as $event) {
- $event->applyViewerTimezone($this->getViewer());
+ if (!$this->skipApplyTimezone) {
+ foreach ($events as $event) {
+ $event->applyViewerTimezone($this->getViewer());
+ }
}
if (!$this->generateGhosts) {
@@ -166,18 +174,20 @@
}
}
+ $max_count = max(100, $this->getRawResultLimit());
+
if ($end) {
$sequence_end = $sequence_start;
while ($date < $end) {
$sequence_end++;
$datetime->modify($modify_key);
$date = $datetime->format('U');
- if ($sequence_end > $this->getRawResultLimit() + $sequence_start) {
+ if ($sequence_end > $max_count + $sequence_start) {
break;
}
}
} else {
- $sequence_end = $this->getRawResultLimit() + $sequence_start;
+ $sequence_end = $max_count + $sequence_start;
}
$sequence_start = max(1, $sequence_start);
@@ -186,9 +196,9 @@
$events[] = $event->generateNthGhost($index, $viewer);
}
- if (count($events) >= $this->getRawResultLimit()) {
+ if (count($events) >= $max_count) {
$events = msort($events, 'getDateFrom');
- $events = array_slice($events, 0, $this->getRawResultLimit(), true);
+ $events = array_slice($events, 0, $max_count, true);
$enforced_end = last($events)->getDateFrom();
}
}
@@ -209,6 +219,7 @@
$sub_query = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer)
->setParentQuery($this)
+ ->setSkipApplyTimezone($this->skipApplyTimezone)
->withInstanceSequencePairs($instance_sequence_pairs)
->execute();
@@ -379,6 +390,7 @@
if (count($instance_of_event_phids) > 0) {
$recurring_events = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer)
+ ->setSkipApplyTimezone($this->skipApplyTimezone)
->withPHIDs($instance_of_event_phids)
->withEventsWithNoParent(true)
->execute();
@@ -422,7 +434,6 @@
}
$events = msort($events, 'getDateFrom');
-
return $events;
}
diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php
--- a/src/applications/people/query/PhabricatorPeopleQuery.php
+++ b/src/applications/people/query/PhabricatorPeopleQuery.php
@@ -392,6 +392,8 @@
$events = id(new PhabricatorCalendarEventQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->setSkipApplyTimezone(true)
+ ->setGenerateGhosts(true)
->withInvitedPHIDs(array_keys($rebuild))
->withIsCancelled(false)
->withDateRange($min_range, $max_range)
@@ -424,8 +426,10 @@
// because of an event, we check again for events after that one ends.
while (true) {
foreach ($events as $event) {
- $from = $event->getDateFromForCache();
- $to = $event->getDateTo();
+ $event_for_timezone = clone $event;
+ $event_for_timezone->applyViewerTimezone($user);
+ $from = $event_for_timezone->getDateFromForCache();
+ $to = $event_for_timezone->getDateTo();
if (($from <= $cursor) && ($to > $cursor)) {
$cursor = $to;
continue 2;

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 21, 12:34 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7228388
Default Alt Text
D13354.diff (4 KB)

Event Timeline