aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2024-10-18 11:45:09 +0200
committerGitHub <noreply@github.com>2024-10-18 11:45:09 +0200
commitd0625645fba049ec9167cf0dc5a23cc63e157e90 (patch)
tree5d38dac54a23ea49ab2f6897a45a0fa9449abeb5 /apps/dav/lib
parent0c67541e76661741ace35b7ac33a3e1a4b120869 (diff)
parenta1681b0756ef784ef7056a3aae3e569a6dcae00e (diff)
downloadnextcloud-server-d0625645fba049ec9167cf0dc5a23cc63e157e90.tar.gz
nextcloud-server-d0625645fba049ec9167cf0dc5a23cc63e157e90.zip
Merge pull request #48765 from nextcloud/dbQueriesExecStmt2
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/CalDAV/Reminder/Backend.php28
-rw-r--r--apps/dav/lib/Command/RemoveInvalidShares.php4
-rw-r--r--apps/dav/lib/Db/DirectMapper.php2
-rw-r--r--apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php23
-rw-r--r--apps/dav/lib/Migration/FixBirthdayCalendarComponent.php16
-rw-r--r--apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php13
-rw-r--r--apps/dav/lib/Migration/RemoveClassifiedEventActivity.php16
-rw-r--r--apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php12
8 files changed, 43 insertions, 71 deletions
diff --git a/apps/dav/lib/CalDAV/Reminder/Backend.php b/apps/dav/lib/CalDAV/Reminder/Backend.php
index f5608760b61..329af3a2f56 100644
--- a/apps/dav/lib/CalDAV/Reminder/Backend.php
+++ b/apps/dav/lib/CalDAV/Reminder/Backend.php
@@ -18,22 +18,16 @@ use OCP\IDBConnection;
*/
class Backend {
- /** @var IDBConnection */
- protected $db;
-
- /** @var ITimeFactory */
- private $timeFactory;
-
/**
* Backend constructor.
*
* @param IDBConnection $db
* @param ITimeFactory $timeFactory
*/
- public function __construct(IDBConnection $db,
- ITimeFactory $timeFactory) {
- $this->db = $db;
- $this->timeFactory = $timeFactory;
+ public function __construct(
+ protected IDBConnection $db,
+ protected ITimeFactory $timeFactory,
+ ) {
}
/**
@@ -50,7 +44,7 @@ class Backend {
->join('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
->join('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'))
->groupBy('cr.event_hash', 'cr.notification_date', 'cr.type', 'cr.id', 'cr.calendar_id', 'cr.object_id', 'cr.is_recurring', 'cr.uid', 'cr.recurrence_id', 'cr.is_recurrence_exception', 'cr.alarm_hash', 'cr.is_relative', 'cr.is_repeat_based', 'co.calendardata', 'c.displayname', 'c.principaluri');
- $stmt = $query->execute();
+ $stmt = $query->executeQuery();
return array_map(
[$this, 'fixRowTyping'],
@@ -69,7 +63,7 @@ class Backend {
$query->select('*')
->from('calendar_reminders')
->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)));
- $stmt = $query->execute();
+ $stmt = $query->executeQuery();
return array_map(
[$this, 'fixRowTyping'],
@@ -122,7 +116,7 @@ class Backend {
'notification_date' => $query->createNamedParameter($notificationDate),
'is_repeat_based' => $query->createNamedParameter($isRepeatBased ? 1 : 0),
])
- ->execute();
+ ->executeStatement();
return $query->getLastInsertId();
}
@@ -139,7 +133,7 @@ class Backend {
$query->update('calendar_reminders')
->set('notification_date', $query->createNamedParameter($newNotificationDate))
->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
- ->execute();
+ ->executeStatement();
}
/**
@@ -153,7 +147,7 @@ class Backend {
$query->delete('calendar_reminders')
->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
- ->execute();
+ ->executeStatement();
}
/**
@@ -166,7 +160,7 @@ class Backend {
$query->delete('calendar_reminders')
->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)))
- ->execute();
+ ->executeStatement();
}
/**
@@ -180,7 +174,7 @@ class Backend {
$query->delete('calendar_reminders')
->where($query->expr()->eq('calendar_id', $query->createNamedParameter($calendarId)))
- ->execute();
+ ->executeStatement();
}
/**
diff --git a/apps/dav/lib/Command/RemoveInvalidShares.php b/apps/dav/lib/Command/RemoveInvalidShares.php
index 18f8de5b4e2..340e878a912 100644
--- a/apps/dav/lib/Command/RemoveInvalidShares.php
+++ b/apps/dav/lib/Command/RemoveInvalidShares.php
@@ -38,7 +38,7 @@ class RemoveInvalidShares extends Command {
$query = $this->connection->getQueryBuilder();
$result = $query->selectDistinct('principaluri')
->from('dav_shares')
- ->execute();
+ ->executeQuery();
while ($row = $result->fetch()) {
$principaluri = $row['principaluri'];
@@ -59,6 +59,6 @@ class RemoveInvalidShares extends Command {
$delete = $this->connection->getQueryBuilder();
$delete->delete('dav_shares')
->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri)));
- $delete->execute();
+ $delete->executeStatement();
}
}
diff --git a/apps/dav/lib/Db/DirectMapper.php b/apps/dav/lib/Db/DirectMapper.php
index 05deffdca94..4fedac35b72 100644
--- a/apps/dav/lib/Db/DirectMapper.php
+++ b/apps/dav/lib/Db/DirectMapper.php
@@ -45,6 +45,6 @@ class DirectMapper extends QBMapper {
$qb->expr()->lt('expiration', $qb->createNamedParameter($expiration))
);
- $qb->execute();
+ $qb->executeStatement();
}
}
diff --git a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
index c7f57dcb117..ecc462e153b 100644
--- a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
+++ b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
@@ -15,18 +15,11 @@ use Sabre\VObject\InvalidDataException;
class CalDAVRemoveEmptyValue implements IRepairStep {
- /** @var IDBConnection */
- private $db;
-
- /** @var CalDavBackend */
- private $calDavBackend;
-
- private LoggerInterface $logger;
-
- public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, LoggerInterface $logger) {
- $this->db = $db;
- $this->calDavBackend = $calDavBackend;
- $this->logger = $logger;
+ public function __construct(
+ private IDBConnection $db,
+ private CalDavBackend $calDavBackend,
+ private LoggerInterface $logger,
+ ) {
}
public function getName() {
@@ -80,7 +73,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
$query = $this->db->getQueryBuilder();
$query->select($query->func()->count('*', 'num_entries'))
->from('calendarobjects');
- $result = $query->execute();
+ $result = $query->executeQuery();
$count = $result->fetchOne();
$result->closeCursor();
@@ -92,7 +85,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
->setMaxResults($chunkSize);
for ($chunk = 0; $chunk < $numChunks; $chunk++) {
$query->setFirstResult($chunk * $chunkSize);
- $result = $query->execute();
+ $result = $query->executeQuery();
while ($row = $result->fetch()) {
if (mb_strpos($row['calendardata'], $pattern) !== false) {
@@ -117,7 +110,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
IQueryBuilder::PARAM_STR
));
- $result = $query->execute();
+ $result = $query->executeQuery();
$rows = $result->fetchAll();
$result->closeCursor();
diff --git a/apps/dav/lib/Migration/FixBirthdayCalendarComponent.php b/apps/dav/lib/Migration/FixBirthdayCalendarComponent.php
index d22e4b82c9f..6833ca2ffa6 100644
--- a/apps/dav/lib/Migration/FixBirthdayCalendarComponent.php
+++ b/apps/dav/lib/Migration/FixBirthdayCalendarComponent.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 ownCloud GmbH.
* SPDX-License-Identifier: AGPL-3.0-only
@@ -12,16 +13,9 @@ use OCP\Migration\IRepairStep;
class FixBirthdayCalendarComponent implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
-
- /**
- * FixBirthdayCalendarComponent constructor.
- *
- * @param IDBConnection $connection
- */
- public function __construct(IDBConnection $connection) {
- $this->connection = $connection;
+ public function __construct(
+ private IDBConnection $connection,
+ ) {
}
/**
@@ -39,7 +33,7 @@ class FixBirthdayCalendarComponent implements IRepairStep {
$updated = $query->update('calendars')
->set('components', $query->createNamedParameter('VEVENT'))
->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
- ->execute();
+ ->executeStatement();
$output->info("$updated birthday calendars updated.");
}
diff --git a/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php b/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php
index 793b5516640..cd4b8b31f4d 100644
--- a/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php
+++ b/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php
@@ -16,21 +16,16 @@ use OCP\Migration\IRepairStep;
class RefreshWebcalJobRegistrar implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
-
- /** @var IJobList */
- private $jobList;
-
/**
* FixBirthdayCalendarComponent constructor.
*
* @param IDBConnection $connection
* @param IJobList $jobList
*/
- public function __construct(IDBConnection $connection, IJobList $jobList) {
- $this->connection = $connection;
- $this->jobList = $jobList;
+ public function __construct(
+ private IDBConnection $connection,
+ private IJobList $jobList,
+ ) {
}
/**
diff --git a/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php b/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php
index 1b97ce6a254..f0d208f4f33 100644
--- a/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php
+++ b/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php
@@ -15,11 +15,9 @@ use OCP\Migration\IRepairStep;
class RemoveClassifiedEventActivity implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
-
- public function __construct(IDBConnection $connection) {
- $this->connection = $connection;
+ public function __construct(
+ private IDBConnection $connection,
+ ) {
}
/**
@@ -58,7 +56,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->from('calendarobjects', 'o')
->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid'))
->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_PRIVATE)));
- $result = $query->execute();
+ $result = $query->executeQuery();
while ($row = $result->fetch()) {
if ($row['principaluri'] === null) {
@@ -69,7 +67,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->setParameter('type', 'calendar')
->setParameter('calendar_id', $row['calendarid'])
->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%');
- $deletedEvents += $delete->execute();
+ $deletedEvents += $delete->executeStatement();
}
$result->closeCursor();
@@ -92,7 +90,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->from('calendarobjects', 'o')
->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid'))
->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_CONFIDENTIAL)));
- $result = $query->execute();
+ $result = $query->executeQuery();
while ($row = $result->fetch()) {
if ($row['principaluri'] === null) {
@@ -104,7 +102,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->setParameter('calendar_id', $row['calendarid'])
->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%')
->setParameter('filtered_name', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '","name":"Busy"') . '%');
- $deletedEvents += $delete->execute();
+ $deletedEvents += $delete->executeStatement();
}
$result->closeCursor();
diff --git a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php
index 798fbad4018..ead2645779b 100644
--- a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php
+++ b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php
@@ -16,11 +16,9 @@ use OCP\Migration\IRepairStep;
class RemoveOrphanEventsAndContacts implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
-
- public function __construct(IDBConnection $connection) {
- $this->connection = $connection;
+ public function __construct(
+ private IDBConnection $connection,
+ ) {
}
/**
@@ -67,7 +65,7 @@ class RemoveOrphanEventsAndContacts implements IRepairStep {
$qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
}
- $result = $qb->execute();
+ $result = $qb->executeQuery();
$orphanItems = [];
while ($row = $result->fetch()) {
@@ -82,7 +80,7 @@ class RemoveOrphanEventsAndContacts implements IRepairStep {
$orphanItemsBatch = array_chunk($orphanItems, 200);
foreach ($orphanItemsBatch as $items) {
$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
- $qb->execute();
+ $qb->executeStatement();
}
}