]> source.dussan.org Git - nextcloud-server.git/commitdiff
Manually iterate over calendardata when oracle is used 24058/head
authorJulius Härtl <jus@bitgrid.net>
Wed, 11 Nov 2020 13:15:52 +0000 (14:15 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Wed, 11 Nov 2020 16:12:25 +0000 (16:12 +0000)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php

index d984902bf5c636f3a86ebbda2b9f7b812d6b8f7d..162edc2f60ce37d99668e5c838700f96bff0bca5 100644 (file)
@@ -23,6 +23,7 @@
 
 namespace OCA\DAV\Migration;
 
+use Doctrine\DBAL\Platforms\OraclePlatform;
 use OCA\DAV\CalDAV\CalDavBackend;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
@@ -98,6 +99,37 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
        }
 
        protected function getInvalidObjects($pattern) {
+               if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
+                       $rows = [];
+                       $chunkSize = 500;
+                       $query = $this->db->getQueryBuilder();
+                       $query->select($query->func()->count('*', 'num_entries'))
+                               ->from('calendarobjects');
+                       $result = $query->execute();
+                       $count = $result->fetchColumn();
+                       $result->closeCursor();
+
+                       $numChunks = ceil($count / $chunkSize);
+
+                       $query = $this->db->getQueryBuilder();
+                       $query->select(['calendarid', 'uri', 'calendardata'])
+                               ->from('calendarobjects')
+                               ->setMaxResults($chunkSize);
+                       for ($chunk = 0; $chunk < $numChunks; $chunk++) {
+                               $query->setFirstResult($chunk * $chunkSize);
+                               $result = $query->execute();
+
+                               while ($row = $result->fetch()) {
+                                       if (mb_strpos($row['calendardata'], $pattern) !== false) {
+                                               unset($row['calendardata']);
+                                               $rows[] = $row;
+                                       }
+                               }
+                               $result->closeCursor();
+                       }
+                       return $rows;
+               }
+
                $query = $this->db->getQueryBuilder();
                $query->select(['calendarid', 'uri'])
                        ->from('calendarobjects')