From 9eb276b20b051c31b349671600961c60d94ad175 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Neukom?= Date: Sun, 17 Jul 2022 18:36:06 +0200 Subject: [PATCH] fix possibly null variables MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Neukom --- apps/dav/lib/CalDAV/BirthdayService.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php index f7fef03dddb..87e33006095 100644 --- a/apps/dav/lib/CalDAV/BirthdayService.php +++ b/apps/dav/lib/CalDAV/BirthdayService.php @@ -14,6 +14,7 @@ declare(strict_types=1); * @author Sven Strickroth * @author Thomas Müller * @author Valdnet <47037905+Valdnet@users.noreply.github.com> + * @author Cédric Neukom * * @license AGPL-3.0 * @@ -86,6 +87,9 @@ class BirthdayService { $targetPrincipals = $this->getAllAffectedPrincipals($addressBookId); $book = $this->cardDavBackEnd->getAddressBookById($addressBookId); + if ($book === null) { + return; + } $targetPrincipals[] = $book['principaluri']; $datesToSync = [ ['postfix' => '', 'field' => 'BDAY'], @@ -101,6 +105,9 @@ class BirthdayService { $reminderOffset = $this->getReminderOffsetForUser($principalUri); $calendar = $this->ensureCalendarExists($principalUri); + if ($calendar === null) { + return; + } foreach ($datesToSync as $type) { $this->updateCalendar($cardUri, $cardData, $book, (int) $calendar['id'], $type, $reminderOffset); } @@ -356,7 +363,7 @@ class BirthdayService { array $book, int $calendarId, array $type, - string $reminderOffset):void { + ?string $reminderOffset):void { $objectUri = $book['uri'] . '-' . $cardUri . $type['postfix'] . '.ics'; $calendarData = $this->buildDateFromContact($cardData, $type['field'], $type['postfix'], $reminderOffset); $existing = $this->calDavBackEnd->getCalendarObject($calendarId, $objectUri); -- 2.39.5