aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-03-22 19:39:17 +0100
committerGitHub <noreply@github.com>2020-03-22 19:39:17 +0100
commit9956922496b37f1b96bddd54836041a224d3d72d (patch)
tree0a998888eb08f1fc4cef522e97ccb8e7b3299511
parent6675f9b403b39949526e1fcce306e4adb32574b3 (diff)
parent42dde6d623b2401cb6ef756635b9424325ca5bc3 (diff)
downloadnextcloud-server-9956922496b37f1b96bddd54836041a224d3d72d.tar.gz
nextcloud-server-9956922496b37f1b96bddd54836041a224d3d72d.zip
Merge pull request #18679 from nextcloud/calDavSearch
fix OCA\DAV\CalDAV\CalDavBackend search $options
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php11
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php9
2 files changed, 11 insertions, 9 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 37dbb3c3f5d..96459566a5a 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -33,6 +33,7 @@
namespace OCA\DAV\CalDAV;
+use DateTime;
use OCA\DAV\Connector\Sabre\Principal;
use OCA\DAV\DAV\Sharing\Backend;
use OCA\DAV\DAV\Sharing\IShareable;
@@ -1551,14 +1552,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
->from('calendarobjects', 'c');
if (isset($options['timerange'])) {
- if (isset($options['timerange']['start'])) {
+ if (isset($options['timerange']['start']) && $options['timerange']['start'] instanceof DateTime) {
$outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence',
- $outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp)));
+ $outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp())));
}
- if (isset($options['timerange']['end'])) {
+ if (isset($options['timerange']['end']) && $options['timerange']['end'] instanceof DateTime) {
$outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence',
- $outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp)));
+ $outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp())));
}
}
@@ -2258,7 +2259,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
} else {
$it = new EventIterator($vObject, (string)$component->UID);
- $maxDate = new \DateTime(self::MAX_DATE);
+ $maxDate = new DateTime(self::MAX_DATE);
if ($it->isInfinite()) {
$lastOccurrence = $maxDate->getTimestamp();
} else {
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
index 868ea2cf88b..8ac4961f19f 100644
--- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
@@ -807,7 +807,7 @@ EOD;
/**
* @dataProvider searchDataProvider
*/
- public function testSearch($isShared, $count) {
+ public function testSearch(bool $isShared, array $searchOptions, int $count) {
$calendarId = $this->createTestCalendar();
$uris = [];
@@ -901,15 +901,16 @@ EOD;
];
$result = $this->backend->search($calendarInfo, 'Test',
- ['SUMMARY', 'LOCATION', 'ATTENDEE'], [], null, null);
+ ['SUMMARY', 'LOCATION', 'ATTENDEE'], $searchOptions, null, null);
$this->assertCount($count, $result);
}
public function searchDataProvider() {
return [
- [false, 4],
- [true, 2],
+ [false, [], 4],
+ [true, ['timerange' => ['start' => new DateTime('2013-09-12 13:00:00'), 'end' => new DateTime('2013-09-12 14:00:00')]], 2],
+ [true, ['timerange' => ['start' => new DateTime('2013-09-12 15:00:00'), 'end' => new DateTime('2013-09-12 16:00:00')]], 0],
];
}