Merge pull request #20190 from nextcloud/backport/18679/stable16
[stable16] fix OCA\DAV\CalDAV\CalDavBackend search $options
This commit is contained in:
commit
8aaa3dd2c2
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
namespace OCA\DAV\CalDAV;
|
namespace OCA\DAV\CalDAV;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
use OCA\DAV\DAV\Sharing\IShareable;
|
use OCA\DAV\DAV\Sharing\IShareable;
|
||||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||||
use OCA\DAV\Connector\Sabre\Principal;
|
use OCA\DAV\Connector\Sabre\Principal;
|
||||||
|
@ -1550,14 +1551,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
->from('calendarobjects', 'c');
|
->from('calendarobjects', 'c');
|
||||||
|
|
||||||
if (isset($options['timerange'])) {
|
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->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->andWhere($outerQuery->expr()->lt('firstoccurence',
|
||||||
$outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp)));
|
$outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2257,7 +2258,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$it = new EventIterator($vObject, (string)$component->UID);
|
$it = new EventIterator($vObject, (string)$component->UID);
|
||||||
$maxDate = new \DateTime(self::MAX_DATE);
|
$maxDate = new DateTime(self::MAX_DATE);
|
||||||
if ($it->isInfinite()) {
|
if ($it->isInfinite()) {
|
||||||
$lastOccurrence = $maxDate->getTimestamp();
|
$lastOccurrence = $maxDate->getTimestamp();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -806,7 +806,7 @@ EOD;
|
||||||
/**
|
/**
|
||||||
* @dataProvider searchDataProvider
|
* @dataProvider searchDataProvider
|
||||||
*/
|
*/
|
||||||
public function testSearch($isShared, $count) {
|
public function testSearch(bool $isShared, array $searchOptions, int $count) {
|
||||||
$calendarId = $this->createTestCalendar();
|
$calendarId = $this->createTestCalendar();
|
||||||
|
|
||||||
$uris = [];
|
$uris = [];
|
||||||
|
@ -900,15 +900,16 @@ EOD;
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $this->backend->search($calendarInfo, 'Test',
|
$result = $this->backend->search($calendarInfo, 'Test',
|
||||||
['SUMMARY', 'LOCATION', 'ATTENDEE'], [], null, null);
|
['SUMMARY', 'LOCATION', 'ATTENDEE'], $searchOptions, null, null);
|
||||||
|
|
||||||
$this->assertCount($count, $result);
|
$this->assertCount($count, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchDataProvider() {
|
public function searchDataProvider() {
|
||||||
return [
|
return [
|
||||||
[false, 4],
|
[false, [], 4],
|
||||||
[true, 2],
|
[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],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue