From 955aa2e6a4d74f9af718b7a504e1cfb50c0241ee Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:42:21 +0200 Subject: [PATCH] chore(db): Apply query prepared statements --- apps/dav/lib/CalDAV/Reminder/Backend.php | 28 ++++----- .../Migration/RefreshWebcalJobRegistrar.php | 15 ++--- .../RemoveClassifiedEventActivity.php | 16 +++-- apps/files_sharing/lib/ShareBackend/File.php | 14 +++-- apps/user_status/lib/Db/UserStatusMapper.php | 4 +- core/Db/LoginFlowV2Mapper.php | 2 +- lib/private/Files/Cache/Storage.php | 28 +++++---- lib/private/Repair/RepairDavShares.php | 24 ++------ lib/private/Share20/DefaultShareProvider.php | 61 +++++++++---------- .../SystemTag/SystemTagObjectMapper.php | 6 +- 10 files changed, 88 insertions(+), 110 deletions(-) diff --git a/apps/dav/lib/CalDAV/Reminder/Backend.php b/apps/dav/lib/CalDAV/Reminder/Backend.php index f5608760b61fd..20ff171459275 100644 --- a/apps/dav/lib/CalDAV/Reminder/Backend.php +++ b/apps/dav/lib/CalDAV/Reminder/Backend.php @@ -18,22 +18,16 @@ */ 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, + protectedITimeFactory $timeFactory, + ) { } /** @@ -50,7 +44,7 @@ public function getRemindersToProcess():array { ->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 @@ public function getAllScheduledRemindersForEvent(int $objectId):array { $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 @@ public function insertReminder(int $calendarId, 'notification_date' => $query->createNamedParameter($notificationDate), 'is_repeat_based' => $query->createNamedParameter($isRepeatBased ? 1 : 0), ]) - ->execute(); + ->executeStatement(); return $query->getLastInsertId(); } @@ -139,7 +133,7 @@ public function updateReminder(int $reminderId, $query->update('calendar_reminders') ->set('notification_date', $query->createNamedParameter($newNotificationDate)) ->where($query->expr()->eq('id', $query->createNamedParameter($reminderId))) - ->execute(); + ->executeStatement(); } /** @@ -153,7 +147,7 @@ public function removeReminder(int $reminderId):void { $query->delete('calendar_reminders') ->where($query->expr()->eq('id', $query->createNamedParameter($reminderId))) - ->execute(); + ->executeStatement(); } /** @@ -166,7 +160,7 @@ public function cleanRemindersForEvent(int $objectId):void { $query->delete('calendar_reminders') ->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId))) - ->execute(); + ->executeStatement(); } /** @@ -180,7 +174,7 @@ public function cleanRemindersForCalendar(int $calendarId):void { $query->delete('calendar_reminders') ->where($query->expr()->eq('calendar_id', $query->createNamedParameter($calendarId))) - ->execute(); + ->executeStatement(); } /** diff --git a/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php b/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php index 793b55166404d..485aece739d89 100644 --- a/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php +++ b/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php @@ -16,21 +16,16 @@ 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, + ) { } /** @@ -47,7 +42,7 @@ public function run(IOutput $output) { $query = $this->connection->getQueryBuilder(); $query->select(['principaluri', 'uri']) ->from('calendarsubscriptions'); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); $count = 0; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { diff --git a/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php b/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php index 1b97ce6a25412..f0d208f4f335e 100644 --- a/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php +++ b/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php @@ -15,11 +15,9 @@ 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 @@ protected function removePrivateEventActivity(): int { ->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 @@ protected function removePrivateEventActivity(): int { ->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 @@ protected function removeConfidentialUncensoredEventActivity(): int { ->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 @@ protected function removeConfidentialUncensoredEventActivity(): int { ->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/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index 0b7ec58aef33d..cd402aa16e226 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -10,7 +10,9 @@ use OC\Files\View; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Helper; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\NotFoundException; +use OCP\IDBConnection; use OCP\Server; use OCP\Share\IShare; use OCP\Share_Backend_File_Dependent; @@ -27,10 +29,10 @@ class File implements Share_Backend_File_Dependent { private $path; - /** @var FederatedShareProvider */ - private $federatedShareProvider; - - public function __construct(?FederatedShareProvider $federatedShareProvider = null) { + public function __construct( + private ?FederatedShareProvider $federatedShareProvider = null, + protected IDBConnection $connection, + ) { if ($federatedShareProvider) { $this->federatedShareProvider = $federatedShareProvider; } else { @@ -183,13 +185,13 @@ protected static function resolveReshares($source) { if (isset($source['parent'])) { $parent = $source['parent']; while (isset($parent)) { - $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); + $qb = $this->connection->getQueryBuilder(); $qb->select('parent', 'uid_owner') ->from('share') ->where( $qb->expr()->eq('id', $qb->createNamedParameter($parent)) ); - $result = $qb->execute(); + $result = $qb->executeQuery(); $item = $result->fetch(); $result->closeCursor(); if (isset($item['parent'])) { diff --git a/apps/user_status/lib/Db/UserStatusMapper.php b/apps/user_status/lib/Db/UserStatusMapper.php index c98f0bf817fa1..feeb2904fb5f5 100644 --- a/apps/user_status/lib/Db/UserStatusMapper.php +++ b/apps/user_status/lib/Db/UserStatusMapper.php @@ -126,7 +126,7 @@ public function clearStatusesOlderThan(int $olderThan, int $now): void { $qb->expr()->eq('status', $qb->createNamedParameter(IUserStatus::ONLINE)) )); - $qb->execute(); + $qb->executeStatement(); } /** @@ -140,7 +140,7 @@ public function clearOlderThanClearAt(int $timestamp): void { ->where($qb->expr()->isNotNull('clear_at')) ->andWhere($qb->expr()->lte('clear_at', $qb->createNamedParameter($timestamp, IQueryBuilder::PARAM_INT))); - $qb->execute(); + $qb->executeStatement(); } diff --git a/core/Db/LoginFlowV2Mapper.php b/core/Db/LoginFlowV2Mapper.php index 8e95cfcb3bc66..32664917cb5f0 100644 --- a/core/Db/LoginFlowV2Mapper.php +++ b/core/Db/LoginFlowV2Mapper.php @@ -71,7 +71,7 @@ public function cleanup(): void { $qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime)) ); - $qb->execute(); + $qb->executeStatement(); } /** diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php index 8d99a268dc043..4ad25916c5a03 100644 --- a/lib/private/Files/Cache/Storage.php +++ b/lib/private/Files/Cache/Storage.php @@ -44,7 +44,11 @@ public static function getGlobalCache() { * @param bool $isAvailable * @throws \RuntimeException */ - public function __construct($storage, $isAvailable, IDBConnection $connection) { + public function __construct( + $storage, + $isAvailable, + protected IDBConnection $connection, + ) { if ($storage instanceof IStorage) { $this->storageId = $storage->getId(); } else { @@ -149,15 +153,15 @@ public function getAvailability() { public function setAvailability($isAvailable, int $delay = 0) { $available = $isAvailable ? 1 : 0; if (!$isAvailable) { - \OC::$server->get(LoggerInterface::class)->info('Storage with ' . $this->storageId . ' marked as unavailable', ['app' => 'lib']); + \OCP\Server::get(LoggerInterface::class)->info('Storage with ' . $this->storageId . ' marked as unavailable', ['app' => 'lib']); } - $query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); + $query = $this->connection->getQueryBuilder(); $query->update('storages') ->set('available', $query->createNamedParameter($available)) ->set('last_checked', $query->createNamedParameter(time() + $delay)) ->where($query->expr()->eq('id', $query->createNamedParameter($this->storageId))); - $query->execute(); + $query->executeStatement(); } /** @@ -179,16 +183,16 @@ public static function remove($storageId) { $storageId = self::adjustStorageId($storageId); $numericId = self::getNumericStorageId($storageId); - $query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); + $query = $this->connection->getQueryBuilder(); $query->delete('storages') ->where($query->expr()->eq('id', $query->createNamedParameter($storageId))); - $query->execute(); + $query->executeStatement(); if (!is_null($numericId)) { - $query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); + $query = $this->connection->getQueryBuilder(); $query->delete('filecache') ->where($query->expr()->eq('storage', $query->createNamedParameter($numericId))); - $query->execute(); + $query->executeStatement(); } } @@ -198,12 +202,10 @@ public static function remove($storageId) { * @param int $mountId */ public static function cleanByMountId(int $mountId) { - $db = \OC::$server->getDatabaseConnection(); - try { - $db->beginTransaction(); + $this->connection->beginTransaction(); - $query = $db->getQueryBuilder(); + $query = $this->connection->getQueryBuilder(); $query->select('storage_id') ->from('mounts') ->where($query->expr()->eq('mount_id', $query->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); @@ -225,7 +227,7 @@ public static function cleanByMountId(int $mountId) { ->where($query->expr()->eq('mount_id', $query->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); $query->executeStatement(); - $db->commit(); + $this->connection->commit(); } catch (\Exception $e) { $db->rollBack(); throw $e; diff --git a/lib/private/Repair/RepairDavShares.php b/lib/private/Repair/RepairDavShares.php index 36e3c397a3926..8199d3dff2784 100644 --- a/lib/private/Repair/RepairDavShares.php +++ b/lib/private/Repair/RepairDavShares.php @@ -23,27 +23,15 @@ class RepairDavShares implements IRepairStep { protected const GROUP_PRINCIPAL_PREFIX = 'principals/groups/'; - /** @var IConfig */ - private $config; - /** @var IDBConnection */ - private $dbc; - /** @var IGroupManager */ - private $groupManager; - /** @var LoggerInterface */ - private $logger; /** @var bool */ private $hintInvalidShares = false; public function __construct( - IConfig $config, - IDBConnection $dbc, - IGroupManager $groupManager, - LoggerInterface $logger, + private IConfig $config, + private IDBConnection $dbc, + private IGroupManager $groupManager, + private LoggerInterface $logger, ) { - $this->config = $config; - $this->dbc = $dbc; - $this->groupManager = $groupManager; - $this->logger = $logger; } /** @@ -64,7 +52,7 @@ protected function repairUnencodedGroupShares() { ->set('principaluri', $updateQuery->createParameter('updatedPrincipalUri')) ->where($updateQuery->expr()->eq('id', $updateQuery->createParameter('shareId'))); - $statement = $qb->execute(); + $statement = $qb->executeQuery(); while ($share = $statement->fetch()) { $gid = substr($share['principaluri'], strlen(self::GROUP_PRINCIPAL_PREFIX)); $decodedGid = urldecode($gid); @@ -93,7 +81,7 @@ protected function repairUnencodedGroupShares() { $updateQuery ->setParameter('updatedPrincipalUri', $fixedPrincipal) ->setParameter('shareId', $share['id']) - ->execute(); + ->executeStatement(); $this->logger->info('Repaired principal for dav share {id} from {old} to {new}', $logParameters); } catch (Exception $e) { $logParameters['message'] = $e->getMessage(); diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index af993b7f314c8..2ad926fbaa78c 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -226,7 +226,7 @@ public function update(\OCP\Share\IShare $share) { ->set('note', $qb->createNamedParameter($share->getNote())) ->set('accepted', $qb->createNamedParameter($share->getStatus())) ->set('reminder_sent', $qb->createNamedParameter($share->getReminderSent(), IQueryBuilder::PARAM_BOOL)) - ->execute(); + ->executeStatement(); } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') @@ -239,7 +239,7 @@ public function update(\OCP\Share\IShare $share) { ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('expiration', $qb->createNamedParameter($expirationDate, IQueryBuilder::PARAM_DATE)) ->set('note', $qb->createNamedParameter($share->getNote())) - ->execute(); + ->executeStatement(); /* * Update all user defined group shares @@ -254,7 +254,7 @@ public function update(\OCP\Share\IShare $share) { ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('expiration', $qb->createNamedParameter($expirationDate, IQueryBuilder::PARAM_DATE)) ->set('note', $qb->createNamedParameter($share->getNote())) - ->execute(); + ->executeStatement(); /* * Now update the permissions for all children that have not set it to 0 @@ -265,7 +265,7 @@ public function update(\OCP\Share\IShare $share) { ->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0))) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('attributes', $qb->createNamedParameter($shareAttributes)) - ->execute(); + ->executeStatement(); } elseif ($share->getShareType() === IShare::TYPE_LINK) { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') @@ -283,7 +283,7 @@ public function update(\OCP\Share\IShare $share) { ->set('note', $qb->createNamedParameter($share->getNote())) ->set('label', $qb->createNamedParameter($share->getLabel())) ->set('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0), IQueryBuilder::PARAM_INT) - ->execute(); + ->executeStatement(); } if ($originalShare->getNote() !== $share->getNote() && $share->getNote() !== '') { @@ -326,7 +326,7 @@ public function acceptShare(IShare $share, string $recipient): IShare { $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) - ->execute(); + ->executeQuery(); $data = $stmt->fetch(); $stmt->closeCursor(); @@ -354,7 +354,7 @@ public function acceptShare(IShare $share, string $recipient): IShare { $qb->update('share') ->set('accepted', $qb->createNamedParameter(IShare::STATUS_ACCEPTED)) ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) - ->execute(); + ->executeStatement(); return $share; } @@ -389,7 +389,7 @@ public function getChildren(\OCP\Share\IShare $parent) { )) ->orderBy('id'); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { $children[] = $this->createShare($data); } @@ -416,7 +416,7 @@ public function delete(\OCP\Share\IShare $share) { $qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))); } - $qb->execute(); + $qb->executeStatement(); } /** @@ -453,7 +453,7 @@ public function deleteFromSelf(IShare $share, $recipient) { $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) - ->execute(); + ->executeQuery(); $data = $stmt->fetch(); @@ -475,7 +475,7 @@ public function deleteFromSelf(IShare $share, $recipient) { $qb->update('share') ->set('permissions', $qb->createNamedParameter(0)) ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) - ->execute(); + ->executeStatement(); } } elseif ($share->getShareType() === IShare::TYPE_USER) { if ($share->getSharedWith() !== $recipient) { @@ -506,7 +506,7 @@ protected function createUserSpecificGroupShare(IShare $share, string $recipient 'file_target' => $qb->createNamedParameter($share->getTarget()), 'permissions' => $qb->createNamedParameter($share->getPermissions()), 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()), - ])->execute(); + ])->executeStatement(); return $qb->getLastInsertId(); } @@ -524,7 +524,7 @@ public function restore(IShare $share, string $recipient): IShare { ->where( $qb->expr()->eq('id', $qb->createNamedParameter($share->getId())) ); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $data = $cursor->fetch(); $cursor->closeCursor(); @@ -541,7 +541,7 @@ public function restore(IShare $share, string $recipient): IShare { $qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)) ); - $qb->execute(); + $qb->executeStatement(); return $this->getShareById($share->getId(), $recipient); } @@ -556,7 +556,7 @@ public function move(\OCP\Share\IShare $share, $recipient) { $qb->update('share') ->set('file_target', $qb->createNamedParameter($share->getTarget())) ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) - ->execute(); + ->executeStatement(); } elseif ($share->getShareType() === IShare::TYPE_GROUP) { // Check if there is a usergroup share $qb = $this->dbConn->getQueryBuilder(); @@ -570,7 +570,7 @@ public function move(\OCP\Share\IShare $share, $recipient) { $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->setMaxResults(1) - ->execute(); + ->executeQuery(); $data = $stmt->fetch(); $stmt->closeCursor(); @@ -596,14 +596,14 @@ public function move(\OCP\Share\IShare $share, $recipient) { 'permissions' => $qb->createNamedParameter($share->getPermissions()), 'attributes' => $qb->createNamedParameter($shareAttributes), 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()), - ])->execute(); + ])->executeStatement(); } else { // Already a usergroup share. Update it. $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->set('file_target', $qb->createNamedParameter($share->getTarget())) ->where($qb->expr()->eq('id', $qb->createNamedParameter($data['id']))) - ->execute(); + ->executeStatement(); } } @@ -727,7 +727,7 @@ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offs $qb->setFirstResult($offset); $qb->orderBy('id'); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $shares = []; while ($data = $cursor->fetch()) { $shares[] = $this->createShare($data); @@ -761,7 +761,7 @@ public function getShareById($id, $recipientId = null) { $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $data = $cursor->fetch(); $cursor->closeCursor(); @@ -805,7 +805,7 @@ public function getSharesByPath(Node $path) { $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) - ->execute(); + ->executeQuery(); $shares = []; while ($data = $cursor->fetch()) { @@ -882,7 +882,7 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset) { $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); } - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { if ($data['fileid'] && $data['path'] === null) { @@ -933,7 +933,6 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset) { $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); } - $groups = array_filter($groups); $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) @@ -946,7 +945,7 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset) { $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { if ($offset > 0) { $offset--; @@ -1099,7 +1098,7 @@ private function resolveGroupShares($shareMap, $userId) { $query->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))); } - $stmt = $query->execute(); + $stmt = $query->executeQuery(); while ($data = $stmt->fetch()) { if (array_key_exists($data['parent'], $shareMap)) { @@ -1179,7 +1178,7 @@ public function userDeleted($uid, $shareType) { return; } - $qb->execute(); + $qb->executeStatement(); } /** @@ -1198,7 +1197,7 @@ public function groupDeleted($gid) { ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $ids = []; while ($row = $cursor->fetch()) { $ids[] = (int)$row['id']; @@ -1215,7 +1214,7 @@ public function groupDeleted($gid) { foreach ($chunks as $chunk) { $qb->setParameter('parents', $chunk, IQueryBuilder::PARAM_INT_ARRAY); - $qb->execute(); + $qb->executeStatement(); } } @@ -1226,7 +1225,7 @@ public function groupDeleted($gid) { $qb->delete('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); - $qb->execute(); + $qb->executeStatement(); } /** @@ -1342,7 +1341,7 @@ public function getAccessList($nodes, $currentAccess) { $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $users = []; $link = false; @@ -1659,7 +1658,7 @@ public function getAllShares(): iterable { ) ); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { try { $share = $this->createShare($data); diff --git a/lib/private/SystemTag/SystemTagObjectMapper.php b/lib/private/SystemTag/SystemTagObjectMapper.php index 157948e6e0c0c..18aae08771471 100644 --- a/lib/private/SystemTag/SystemTagObjectMapper.php +++ b/lib/private/SystemTag/SystemTagObjectMapper.php @@ -97,7 +97,7 @@ public function getObjectIdsForTags($tagIds, string $objectType, int $limit = 0, $objectIds = []; - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $objectIds[] = $row['objectid']; } @@ -187,7 +187,7 @@ public function unassignTags(string $objId, string $objectType, $tagIds): void { ->setParameter('objectid', $objId) ->setParameter('objecttype', $objectType) ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY) - ->execute(); + ->executeStatement(); $this->dispatcher->dispatch(MapperEvent::EVENT_UNASSIGN, new MapperEvent( MapperEvent::EVENT_UNASSIGN, @@ -226,7 +226,7 @@ public function haveTag($objIds, string $objectType, string $tagId, bool $all = ->setParameter('tagid', $tagId) ->setParameter('objecttype', $objectType); - $result = $query->execute(); + $result = $query->executeQuery(); $row = $result->fetch(\PDO::FETCH_NUM); $result->closeCursor();