From dc558b5538cd9c4872eacbfa5ca108f1c6e4f40d Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Thu, 8 Dec 2022 15:32:03 -0700 Subject: [PATCH] Fix NULL pointer exception in some circumstances from Calendar's homepage Summary: After importing specific weird events, for example from Google Calendar (bleah), it can happen that the Calendar's homepage becomes broken. This was the Exception error shown to video: "Call to a member function getEventsBetween() on null" It was happening since this method can return NULL: PhabricatorCalendarEventQuery#newRecurrenceSet() This changeset verifies this condition from the Calendar's homepage. Closes T15136 Test Plan: I tried in my server. I've executed the syntax lint. On my local machine I was not able to run "arc diff" since it tries to connect to root@localhost for some reasons. Reviewers: O1 Blessed Committers, 20after4 Reviewed By: O1 Blessed Committers, 20after4 Subscribers: 0, Cigaryno, 20after4, speck, tobiaswiese, Matthew Tags: #calendar Maniphest Tasks: T15136 Differential Revision: https://we.phorge.it/D25060 --- .../calendar/query/PhabricatorCalendarEventQuery.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php index db50bb4d77..d20250e711 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php @@ -222,12 +222,16 @@ final class PhabricatorCalendarEventQuery $limit = $this->getRecurrenceLimit($event, $raw_limit); + // note that this can be NULL for some imported events $set = $event->newRecurrenceSet(); - $recurrences = $set->getEventsBetween( - $start_date, - $end_date, - $limit + 1); + $recurrences = array(); + if ($set) { + $recurrences = $set->getEventsBetween( + $start_date, + $end_date, + $limit + 1); + } // We're generating events from the beginning and then filtering them // here (instead of only generating events starting at the start date)