summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-11-11 17:09:28 +0100
committerGitHub <noreply@github.com>2020-11-11 17:09:28 +0100
commit9db321cf11637089f9e5ebd67ea6d909fc81d000 (patch)
treeabd24ee9f49277b7eeb7766257986b1ae0978b18 /apps/dav/lib
parent48f1f961b9e01249a9e896fc0fabb7fbf0a42f8b (diff)
parente69655e9a6a9b7efd4c10176758b9881271b7e84 (diff)
downloadnextcloud-server-9db321cf11637089f9e5ebd67ea6d909fc81d000.tar.gz
nextcloud-server-9db321cf11637089f9e5ebd67ea6d909fc81d000.zip
Merge pull request #24054 from nextcloud/bugfix/noid/calendar-repair-oracle
Manually iterate over calendardata when oracle is used
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
index d984902bf5c..162edc2f60c 100644
--- a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
+++ b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
@@ -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')