From 6de2eccb7bc536e524a987ecca53238134b8e7b9 Mon Sep 17 00:00:00 2001 From: Jamie McClelland <jm@mayfirst.org> Date: Mon, 7 Aug 2023 10:49:13 -0400 Subject: optimize calendar search query see https://github.com/nextcloud/calendar/issues/4758 Signed-off-by: Jamie McClelland <jm@mayfirst.org> --- apps/dav/lib/CalDAV/CalDavBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 1d526d89e6b..e4cc77fedc5 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1847,7 +1847,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription // only return public items for shared calendars for now if (isset($calendarInfo['{http://owncloud.org/ns}owner-principal']) === false || $calendarInfo['principaluri'] !== $calendarInfo['{http://owncloud.org/ns}owner-principal']) { - $innerQuery->andWhere($innerQuery->expr()->eq('c.classification', + $outerQuery->andWhere($outerQuery->expr()->eq('c.classification', $outerQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC))); } -- cgit v1.2.3 From b025e67d8d9763a266ccc21997e753badb626d3e Mon Sep 17 00:00:00 2001 From: Jamie McClelland <jm@mayfirst.org> Date: Mon, 7 Aug 2023 13:35:08 -0400 Subject: ensure outerquery ->where() function doesn't clobber earier ->andWhere() Signed-off-by: Jamie McClelland <jm@mayfirst.org> --- apps/dav/lib/CalDAV/CalDavBackend.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index e4cc77fedc5..f4113de50b9 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1845,6 +1845,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->andWhere($innerQuery->expr()->eq('op.calendartype', $outerQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR))); + $outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri') + ->from('calendarobjects', 'c') + ->where($outerQuery->expr()->isNull('deleted_at')); + // only return public items for shared calendars for now if (isset($calendarInfo['{http://owncloud.org/ns}owner-principal']) === false || $calendarInfo['principaluri'] !== $calendarInfo['{http://owncloud.org/ns}owner-principal']) { $outerQuery->andWhere($outerQuery->expr()->eq('c.classification', @@ -1866,10 +1870,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $this->db->escapeLikeParameter($pattern) . '%'))); } - $outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri') - ->from('calendarobjects', 'c') - ->where($outerQuery->expr()->isNull('deleted_at')); - if (isset($options['timerange'])) { if (isset($options['timerange']['start']) && $options['timerange']['start'] instanceof DateTimeInterface) { $outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence', -- cgit v1.2.3