Skip to content

Commit

Permalink
🥅 — Catch MaxInstancesExceededException on calendar events
Browse files Browse the repository at this point in the history
Signed-off-by: Luc Didry <luc@didry.org>
  • Loading branch information
ldidry committed Sep 12, 2024
1 parent b6c2866 commit 8580389
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
use Sabre\VObject\Reader;
use Sabre\VObject\Recur\EventIterator;
use Sabre\VObject\Recur\NoInstancesException;
use Sabre\VObject\Recur\MaxInstancesExceededException;
use function array_column;
use function array_map;
use function array_merge;
Expand Down Expand Up @@ -1723,6 +1724,12 @@ public function calendarQuery($calendarId, array $filters, $calendarType = self:
'exception' => $ex,
]);
continue;
} catch (MaxInstancesExceededException $ex) {
$this->logger->warning('Caught max instances exceeded exception for calendar data. This usually indicates too much recurring (more than 3500) event in calendar data. Object uri: '.$row['uri'], [
'app' => 'dav',
'exception' => $ex,
]);
continue;
}

if (!$matches) {
Expand Down Expand Up @@ -2072,24 +2079,32 @@ private function searchCalendarObjects(IQueryBuilder $query, DateTimeInterface|n
continue;
}

$isValid = $this->validateFilterForObject($row, [
'name' => 'VCALENDAR',
'comp-filters' => [
[
'name' => 'VEVENT',
'comp-filters' => [],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => [
'start' => $start,
'end' => $end,
try {
$isValid = $this->validateFilterForObject($row, [
'name' => 'VCALENDAR',
'comp-filters' => [
[
'name' => 'VEVENT',
'comp-filters' => [],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => [
'start' => $start,
'end' => $end,
],
],
],
],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => null,
]);
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => null,
]);
} catch (MaxInstancesExceededException $ex) {
$this->logger->warning('Caught max instances exceeded exception for calendar data. This usually indicates too much recurring (more than 3500) event in calendar data. Object uri: '.$row['uri'], [
'app' => 'dav',
'exception' => $ex,
]);
continue;
}

if (is_resource($row['calendardata'])) {
// Put the stream back to the beginning so it can be read another time
Expand Down

0 comments on commit 8580389

Please sign in to comment.