Skip to content

Commit cfef1cb

Browse files
Merge pull request #48085 from nextcloud/backport/47924/stable28
[stable28] 🥅 — Catch MaxInstancesExceededException on calendar events
2 parents c10a980 + df397d9 commit cfef1cb

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
@@ -99,6 +99,7 @@
9999
use Sabre\VObject\Property;
100100
use Sabre\VObject\Reader;
101101
use Sabre\VObject\Recur\EventIterator;
102+
use Sabre\VObject\Recur\MaxInstancesExceededException;
102103
use Sabre\VObject\Recur\NoInstancesException;
103104
use function array_column;
104105
use function array_map;
@@ -1711,6 +1712,12 @@ public function calendarQuery($calendarId, array $filters, $calendarType = self:
17111712
'exception' => $ex,
17121713
]);
17131714
continue;
1715+
} catch (MaxInstancesExceededException $ex) {
1716+
$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'], [
1717+
'app' => 'dav',
1718+
'exception' => $ex,
1719+
]);
1720+
continue;
17141721
}
17151722

17161723
if (!$matches) {
@@ -2060,24 +2067,32 @@ private function searchCalendarObjects(IQueryBuilder $query, DateTimeInterface|n
20602067
continue;
20612068
}
20622069

2063-
$isValid = $this->validateFilterForObject($row, [
2064-
'name' => 'VCALENDAR',
2065-
'comp-filters' => [
2066-
[
2067-
'name' => 'VEVENT',
2068-
'comp-filters' => [],
2069-
'prop-filters' => [],
2070-
'is-not-defined' => false,
2071-
'time-range' => [
2072-
'start' => $start,
2073-
'end' => $end,
2070+
try {
2071+
$isValid = $this->validateFilterForObject($row, [
2072+
'name' => 'VCALENDAR',
2073+
'comp-filters' => [
2074+
[
2075+
'name' => 'VEVENT',
2076+
'comp-filters' => [],
2077+
'prop-filters' => [],
2078+
'is-not-defined' => false,
2079+
'time-range' => [
2080+
'start' => $start,
2081+
'end' => $end,
2082+
],
20742083
],
20752084
],
2076-
],
2077-
'prop-filters' => [],
2078-
'is-not-defined' => false,
2079-
'time-range' => null,
2080-
]);
2085+
'prop-filters' => [],
2086+
'is-not-defined' => false,
2087+
'time-range' => null,
2088+
]);
2089+
} catch (MaxInstancesExceededException $ex) {
2090+
$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'], [
2091+
'app' => 'dav',
2092+
'exception' => $ex,
2093+
]);
2094+
continue;
2095+
}
20812096

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

0 commit comments

Comments
 (0)