Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable24] fix(dav): catch MaxInstancesExceededException for recurring events without end date #36234

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 39 additions & 34 deletions apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,49 +462,54 @@ private function deleteOrProcessNext(array $reminder,
return;
}

while ($iterator->valid()) {
$event = $iterator->getEventObject();

// Recurrence-exceptions are handled separately, so just ignore them here
if (\in_array($event, $recurrenceExceptions, true)) {
$iterator->next();
continue;
}

$recurrenceId = $this->getEffectiveRecurrenceIdOfVEvent($event);
if ($reminder['recurrence_id'] >= $recurrenceId) {
$iterator->next();
continue;
}
try {
while ($iterator->valid()) {
$event = $iterator->getEventObject();

foreach ($event->VALARM as $valarm) {
/** @var VAlarm $valarm */
$alarmHash = $this->getAlarmHash($valarm);
if ($alarmHash !== $reminder['alarm_hash']) {
// Recurrence-exceptions are handled separately, so just ignore them here
if (\in_array($event, $recurrenceExceptions, true)) {
$iterator->next();
continue;
}

$triggerTime = $valarm->getEffectiveTriggerTime();

// If effective trigger time is in the past
// just skip and generate for next event
$diff = $now->diff($triggerTime);
if ($diff->invert === 1) {
$recurrenceId = $this->getEffectiveRecurrenceIdOfVEvent($event);
if ($reminder['recurrence_id'] >= $recurrenceId) {
$iterator->next();
continue;
}

$this->backend->removeReminder($reminder['id']);
$alarms = $this->getRemindersForVAlarm($valarm, [
'calendarid' => $reminder['calendar_id'],
'id' => $reminder['object_id'],
], $reminder['event_hash'], $alarmHash, true, false);
$this->writeRemindersToDatabase($alarms);
foreach ($event->VALARM as $valarm) {

Check notice

Code scanning / Psalm

PossiblyNullIterator

Cannot iterate over nullable var Sabre\VObject\Property|null
/** @var VAlarm $valarm */
$alarmHash = $this->getAlarmHash($valarm);
if ($alarmHash !== $reminder['alarm_hash']) {
continue;
}

// Abort generating reminders after creating one successfully
return;
}
$triggerTime = $valarm->getEffectiveTriggerTime();

$iterator->next();
// If effective trigger time is in the past
// just skip and generate for next event
$diff = $now->diff($triggerTime);
if ($diff->invert === 1) {
continue;
}

$this->backend->removeReminder($reminder['id']);
$alarms = $this->getRemindersForVAlarm($valarm, [
'calendarid' => $reminder['calendar_id'],
'id' => $reminder['object_id'],
], $reminder['event_hash'], $alarmHash, true, false);
$this->writeRemindersToDatabase($alarms);

// Abort generating reminders after creating one successfully
return;
}

$iterator->next();
}
} catch (MaxInstancesExceededException $e) {

Check failure

Code scanning / Psalm

UndefinedClass

Class, interface or enum named OCA\DAV\CalDAV\Reminder\MaxInstancesExceededException does not exist
// Using debug logger as this isn't really an error
$this->logger->debug('Recurrence with too many instances detected, skipping VEVENT', ['exception' => $e]);

Check failure

Code scanning / Psalm

UndefinedThisPropertyFetch

Instance property OCA\DAV\CalDAV\Reminder\ReminderService::$logger is not defined
}

$this->backend->removeReminder($reminder['id']);
Expand Down