Skip to content

Commit 54f40d6

Browse files
committed
🥅 — Catch MaxInstancesExceededException on calendar events
Signed-off-by: Luc Didry <luc@didry.org>
1 parent b6c2866 commit 54f40d6

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
use Sabre\VObject\Reader;
6767
use Sabre\VObject\Recur\EventIterator;
6868
use Sabre\VObject\Recur\NoInstancesException;
69+
use Sabre\VObject\Recur\MaxInstancesExceededException;
6970
use function array_column;
7071
use function array_map;
7172
use function array_merge;
@@ -1723,6 +1724,12 @@ public function calendarQuery($calendarId, array $filters, $calendarType = self:
17231724
'exception' => $ex,
17241725
]);
17251726
continue;
1727+
} catch (MaxInstancesExceededException $ex) {
1728+
$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'], [
1729+
'app' => 'dav',
1730+
'exception' => $ex,
1731+
]);
1732+
continue;
17261733
}
17271734

17281735
if (!$matches) {
@@ -2072,24 +2079,32 @@ private function searchCalendarObjects(IQueryBuilder $query, DateTimeInterface|n
20722079
continue;
20732080
}
20742081

2075-
$isValid = $this->validateFilterForObject($row, [
2076-
'name' => 'VCALENDAR',
2077-
'comp-filters' => [
2078-
[
2079-
'name' => 'VEVENT',
2080-
'comp-filters' => [],
2081-
'prop-filters' => [],
2082-
'is-not-defined' => false,
2083-
'time-range' => [
2084-
'start' => $start,
2085-
'end' => $end,
2082+
try {
2083+
$isValid = $this->validateFilterForObject($row, [
2084+
'name' => 'VCALENDAR',
2085+
'comp-filters' => [
2086+
[
2087+
'name' => 'VEVENT',
2088+
'comp-filters' => [],
2089+
'prop-filters' => [],
2090+
'is-not-defined' => false,
2091+
'time-range' => [
2092+
'start' => $start,
2093+
'end' => $end,
2094+
],
20862095
],
20872096
],
2088-
],
2089-
'prop-filters' => [],
2090-
'is-not-defined' => false,
2091-
'time-range' => null,
2092-
]);
2097+
'prop-filters' => [],
2098+
'is-not-defined' => false,
2099+
'time-range' => null,
2100+
]);
2101+
} catch (MaxInstancesExceededException $ex) {
2102+
$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'], [
2103+
'app' => 'dav',
2104+
'exception' => $ex,
2105+
]);
2106+
continue;
2107+
}
20932108

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

0 commit comments

Comments
 (0)