Skip to content
Merged
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
36 changes: 35 additions & 1 deletion apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
use function array_values;
use function explode;
use function is_array;
use function is_resource;
use function pathinfo;
use function rewind;
use function sprintf;
use function str_replace;
use function strtolower;
Expand Down Expand Up @@ -1900,7 +1902,39 @@ public function search(array $calendarInfo, $pattern, array $searchProperties,
}

$result = $outerQuery->executeQuery();
$calendarObjects = $result->fetchAll();
$calendarObjects = array_filter($result->fetchAll(), function (array $row) use ($options) {
$start = $options['timerange']['start'] ?? null;
$end = $options['timerange']['end'] ?? null;

if ($start === null || !($start instanceof DateTimeInterface) || $end === null || !($end instanceof DateTimeInterface)) {
// No filter required
return true;
}

$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,
]);
if (is_resource($row['calendardata'])) {
// Put the stream back to the beginning so it can be read another time
rewind($row['calendardata']);
}
return $isValid;
});
$result->closeCursor();

return array_map(function ($o) {
Expand Down