diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-10-17 11:29:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 11:29:46 +0200 |
commit | 40fd76f69e601ab5579e8ce9b81318d3924dd463 (patch) | |
tree | 0209b59a3dff7bd3a50629dfb6c8376e02dc43af /apps | |
parent | 4100f583f03464978e622f5765bbef33e363c97f (diff) | |
parent | c254855222ca2776ccaa9c362b84295391cdd208 (diff) | |
download | nextcloud-server-40fd76f69e601ab5579e8ce9b81318d3924dd463.tar.gz nextcloud-server-40fd76f69e601ab5579e8ce9b81318d3924dd463.zip |
Merge pull request #48724 from nextcloud/dbQueriesExecStmt
chore(db): Apply query prepared statements
Diffstat (limited to 'apps')
13 files changed, 102 insertions, 170 deletions
diff --git a/apps/contactsinteraction/lib/Db/CardSearchDao.php b/apps/contactsinteraction/lib/Db/CardSearchDao.php index 09fa4711adb..b1dadd6cfbc 100644 --- a/apps/contactsinteraction/lib/Db/CardSearchDao.php +++ b/apps/contactsinteraction/lib/Db/CardSearchDao.php @@ -15,10 +15,10 @@ use function is_resource; use function stream_get_contents; class CardSearchDao { - private IDBConnection $db; - public function __construct(IDBConnection $db) { - $this->db = $db; + public function __construct( + private IDBConnection $db, + ) { } public function findExisting(IUser $user, @@ -65,7 +65,7 @@ class CardSearchDao { ->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) ->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) ->setMaxResults(1); - $result = $cardQuery->execute(); + $result = $cardQuery->executeQuery(); /** @var string|resource|false $card */ $card = $result->fetchOne(); diff --git a/apps/dav/lib/CalDAV/Schedule/IMipService.php b/apps/dav/lib/CalDAV/Schedule/IMipService.php index a101cb05db3..5b6efba9909 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipService.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipService.php @@ -27,13 +27,7 @@ use Sabre\VObject\Recur\EventIterator; class IMipService { - private URLGenerator $urlGenerator; - private IConfig $config; - private IDBConnection $db; - private ISecureRandom $random; - private L10NFactory $l10nFactory; private IL10N $l10n; - private ITimeFactory $timeFactory; /** @var string[] */ private const STRING_DIFF = [ @@ -43,20 +37,16 @@ class IMipService { 'meeting_location' => 'LOCATION' ]; - public function __construct(URLGenerator $urlGenerator, - IConfig $config, - IDBConnection $db, - ISecureRandom $random, - L10NFactory $l10nFactory, - ITimeFactory $timeFactory) { - $this->urlGenerator = $urlGenerator; - $this->config = $config; - $this->db = $db; - $this->random = $random; - $this->l10nFactory = $l10nFactory; + public function __construct( + private URLGenerator $urlGenerator, + private IConfig $config, + private IDBConnection $db, + private ISecureRandom $random, + private L10NFactory $l10nFactory, + private ITimeFactory $timeFactory, + ) { $default = $this->l10nFactory->findGenericLanguage(); $this->l10n = $this->l10nFactory->get('dav', $default); - $this->timeFactory = $timeFactory; } /** @@ -912,7 +902,7 @@ class IMipService { 'expiration' => $query->createNamedParameter($lastOccurrence), 'uid' => $query->createNamedParameter($uid) ]) - ->execute(); + ->executeStatement(); return $token; } diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index b94da9fa7ed..f7d0a888efd 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -200,7 +200,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $addressBooks = []; - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $addressBooks[$row['id']] = [ 'id' => $row['id'], @@ -395,7 +395,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { 'synctoken' => $query->createParameter('synctoken'), ]) ->setParameters($values) - ->execute(); + ->executeStatement(); $addressBookId = $query->getLastInsertId(); return [ @@ -479,7 +479,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $cards = []; - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $row['etag'] = '"' . $row['etag'] . '"'; @@ -516,7 +516,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri))) ->setMaxResults(1); - $result = $query->execute(); + $result = $query->executeQuery(); $row = $result->fetch(); if (!$row) { return false; @@ -560,7 +560,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { foreach ($chunks as $uris) { $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $row['etag'] = '"' . $row['etag'] . '"'; @@ -634,7 +634,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { 'etag' => $query->createNamedParameter($etag), 'uid' => $query->createNamedParameter($uid), ]) - ->execute(); + ->executeStatement(); $etagCacheKey = "$addressBookId#$cardUri"; $this->etagCache[$etagCacheKey] = $etag; @@ -697,7 +697,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->set('uid', $query->createNamedParameter($uid)) ->where($query->expr()->eq('uri', $query->createNamedParameter($cardUri))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))) - ->execute(); + ->executeStatement(); $this->etagCache[$etagCacheKey] = $etag; @@ -1165,7 +1165,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { */ } - $result = $query2->execute(); + $result = $query2->executeQuery(); $matches = $result->fetchAll(); $result->closeCursor(); $matches = array_map(function ($match) { @@ -1207,7 +1207,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->from($this->dbCardsPropertiesTable) ->where($query->expr()->eq('name', $query->createNamedParameter($name))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($bookId))) - ->execute(); + ->executeQuery(); $all = $result->fetchAll(PDO::FETCH_COLUMN); $result->closeCursor(); @@ -1227,7 +1227,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->where($query->expr()->eq('id', $query->createParameter('id'))) ->setParameter('id', $id); - $result = $query->execute(); + $result = $query->executeQuery(); $uri = $result->fetch(); $result->closeCursor(); @@ -1251,7 +1251,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $query->select('*')->from($this->dbCardsTable) ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); - $queryResult = $query->execute(); + $queryResult = $query->executeQuery(); $contact = $queryResult->fetch(); $queryResult->closeCursor(); @@ -1324,7 +1324,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $query->setParameter('name', $property->name); $query->setParameter('value', mb_strcut($property->getValue(), 0, 254)); $query->setParameter('preferred', $preferred); - $query->execute(); + $query->executeStatement(); } }, $this->db); } @@ -1350,7 +1350,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $query->delete($this->dbCardsPropertiesTable) ->where($query->expr()->eq('cardid', $query->createNamedParameter($cardId))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); - $query->execute(); + $query->executeStatement(); } /** @@ -1362,7 +1362,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); - $result = $query->execute(); + $result = $query->executeQuery(); $cardIds = $result->fetch(); $result->closeCursor(); diff --git a/apps/dav/lib/Migration/BuildCalendarSearchIndex.php b/apps/dav/lib/Migration/BuildCalendarSearchIndex.php index 592a6f85bdc..b157934a1ff 100644 --- a/apps/dav/lib/Migration/BuildCalendarSearchIndex.php +++ b/apps/dav/lib/Migration/BuildCalendarSearchIndex.php @@ -13,26 +13,11 @@ use OCP\Migration\IRepairStep; class BuildCalendarSearchIndex implements IRepairStep { - /** @var IDBConnection */ - private $db; - - /** @var IJobList */ - private $jobList; - - /** @var IConfig */ - private $config; - - /** - * @param IDBConnection $db - * @param IJobList $jobList - * @param IConfig $config - */ - public function __construct(IDBConnection $db, - IJobList $jobList, - IConfig $config) { - $this->db = $db; - $this->jobList = $jobList; - $this->config = $config; + public function __construct( + private IDBConnection $db, + private IJobList $jobList, + private IConfig $config, + ) { } /** @@ -55,7 +40,7 @@ class BuildCalendarSearchIndex implements IRepairStep { $query = $this->db->getQueryBuilder(); $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) ->from('calendarobjects'); - $result = $query->execute(); + $result = $query->executeQuery(); $maxId = (int)$result->fetchOne(); $result->closeCursor(); diff --git a/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php b/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php index f9a12ecbfae..7f74390f883 100644 --- a/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php +++ b/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php @@ -22,15 +22,6 @@ use OCP\Migration\IRepairStep; */ class RegisterBuildReminderIndexBackgroundJob implements IRepairStep { - /** @var IDBConnection */ - private $db; - - /** @var IJobList */ - private $jobList; - - /** @var IConfig */ - private $config; - /** @var string */ private const CONFIG_KEY = 'buildCalendarReminderIndex'; @@ -39,12 +30,11 @@ class RegisterBuildReminderIndexBackgroundJob implements IRepairStep { * @param IJobList $jobList * @param IConfig $config */ - public function __construct(IDBConnection $db, - IJobList $jobList, - IConfig $config) { - $this->db = $db; - $this->jobList = $jobList; - $this->config = $config; + public function __construct( + private IDBConnection $db, + private IJobList $jobList, + private IConfig $config, + ) { } /** @@ -67,7 +57,7 @@ class RegisterBuildReminderIndexBackgroundJob implements IRepairStep { $query = $this->db->getQueryBuilder(); $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) ->from('calendarobjects'); - $result = $query->execute(); + $result = $query->executeQuery(); $maxId = (int)$result->fetchOne(); $result->closeCursor(); diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index f349bb2a6fc..da55b9a03d7 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -267,7 +267,7 @@ class FederatedShareProvider implements IShareProvider { $query->select('*')->from($this->externalShareTable) ->where($query->expr()->eq('user', $query->createNamedParameter($share->getShareOwner()))) ->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget()))); - $qResult = $query->execute(); + $qResult = $query->executeQuery(); $result = $qResult->fetchAll(); $qResult->closeCursor(); @@ -313,7 +313,7 @@ class FederatedShareProvider implements IShareProvider { */ $qb->setValue('file_target', $qb->createNamedParameter('')); - $qb->execute(); + $qb->executeStatement(); return $qb->getLastInsertId(); } @@ -334,7 +334,7 @@ class FederatedShareProvider implements IShareProvider { ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE)) - ->execute(); + ->executeStatement(); // send the updated permission to the owner/initiator, if they are not the same if ($share->getShareOwner() !== $share->getSharedBy()) { @@ -374,7 +374,7 @@ class FederatedShareProvider implements IShareProvider { $query->update('share') ->where($query->expr()->eq('id', $query->createNamedParameter($shareId))) ->set('token', $query->createNamedParameter($token)) - ->execute(); + ->executeStatement(); } /** @@ -392,7 +392,7 @@ class FederatedShareProvider implements IShareProvider { 'remote_id' => $query->createNamedParameter($remoteId), ] ); - $query->execute(); + $query->executeStatement(); } /** @@ -406,7 +406,7 @@ class FederatedShareProvider implements IShareProvider { $query = $this->dbConnection->getQueryBuilder(); $query->select('remote_id')->from('federated_reshares') ->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId()))); - $result = $query->execute(); + $result = $query->executeQuery(); $data = $result->fetch(); $result->closeCursor(); @@ -444,7 +444,7 @@ class FederatedShareProvider implements IShareProvider { ->andWhere($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY))) ->orderBy('id'); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { $children[] = $this->createShareObject($data); } @@ -524,12 +524,12 @@ class FederatedShareProvider implements IShareProvider { $qb->delete('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId))) ->andWhere($qb->expr()->neq('share_type', $qb->createNamedParameter(IShare::TYPE_CIRCLE))); - $qb->execute(); + $qb->executeStatement(); $qb = $this->dbConnection->getQueryBuilder(); $qb->delete('federated_reshares') ->where($qb->expr()->eq('share_id', $qb->createNamedParameter($shareId))); - $qb->execute(); + $qb->executeStatement(); } /** @@ -583,7 +583,7 @@ class FederatedShareProvider implements IShareProvider { $qb->orderBy('id'); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $shares = []; while ($data = $cursor->fetch()) { $shares[$data['fileid']][] = $this->createShareObject($data); @@ -639,7 +639,7 @@ class FederatedShareProvider implements IShareProvider { $qb->setFirstResult($offset); $qb->orderBy('id'); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $shares = []; while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); @@ -660,7 +660,7 @@ class FederatedShareProvider implements IShareProvider { ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) ->andWhere($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY))); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $data = $cursor->fetch(); $cursor->closeCursor(); @@ -691,7 +691,7 @@ class FederatedShareProvider implements IShareProvider { ->from('share') ->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId()))) ->andWhere($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY))) - ->execute(); + ->executeQuery(); $shares = []; while ($data = $cursor->fetch()) { @@ -731,7 +731,7 @@ class FederatedShareProvider implements IShareProvider { $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); } - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); @@ -756,7 +756,7 @@ class FederatedShareProvider implements IShareProvider { ->from('share') ->where($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY))) ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) - ->execute(); + ->executeQuery(); $data = $cursor->fetch(); @@ -787,7 +787,7 @@ class FederatedShareProvider implements IShareProvider { ->from('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $data = $cursor->fetch(); $cursor->closeCursor(); @@ -884,7 +884,7 @@ class FederatedShareProvider implements IShareProvider { $qb->delete('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))) ->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid))) - ->execute(); + ->executeStatement(); } /** @@ -1015,7 +1015,7 @@ class FederatedShareProvider implements IShareProvider { $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); if ($currentAccess === false) { $remote = $cursor->fetch() !== false; @@ -1048,7 +1048,7 @@ class FederatedShareProvider implements IShareProvider { ) ); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { try { $share = $this->createShareObject($data); diff --git a/apps/files/lib/Command/DeleteOrphanedFiles.php b/apps/files/lib/Command/DeleteOrphanedFiles.php index 4bbee0b45f4..966351e4da0 100644 --- a/apps/files/lib/Command/DeleteOrphanedFiles.php +++ b/apps/files/lib/Command/DeleteOrphanedFiles.php @@ -147,11 +147,11 @@ class DeleteOrphanedFiles extends Command { $deletedInLastChunk = self::CHUNK_SIZE; while ($deletedInLastChunk === self::CHUNK_SIZE) { $deletedInLastChunk = 0; - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $deletedInLastChunk++; $deletedEntries += $deleteQuery->setParameter('storageid', (int)$row['storage_id']) - ->execute(); + ->executeStatement(); } $result->closeCursor(); } diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php index 6fb7e01271e..3820f6b0d96 100644 --- a/apps/files_external/lib/Service/DBConfigService.php +++ b/apps/files_external/lib/Service/DBConfigService.php @@ -24,25 +24,10 @@ class DBConfigService { public const APPLICABLE_TYPE_GROUP = 2; public const APPLICABLE_TYPE_USER = 3; - /** - * @var IDBConnection - */ - private $connection; - - /** - * @var ICrypto - */ - private $crypto; - - /** - * DBConfigService constructor. - * - * @param IDBConnection $connection - * @param ICrypto $crypto - */ - public function __construct(IDBConnection $connection, ICrypto $crypto) { - $this->connection = $connection; - $this->crypto = $crypto; + public function __construct( + private IDBConnection $connection, + private ICrypto $crypto, + ) { } public function getMountById(int $mountId): ?array { @@ -112,7 +97,7 @@ class DBConfigService { ) ) ->groupBy(['a.mount_id']); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); $result = $stmt->fetchAll(); $stmt->closeCursor(); @@ -243,7 +228,7 @@ class DBConfigService { 'priority' => $builder->createNamedParameter($priority, IQueryBuilder::PARAM_INT), 'type' => $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT) ]); - $query->execute(); + $query->executeStatement(); return $query->getLastInsertId(); } @@ -256,22 +241,22 @@ class DBConfigService { $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_mounts') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_applicable') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_config') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_options') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -285,7 +270,7 @@ class DBConfigService { ->set('mount_point', $builder->createNamedParameter($newMountPoint)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -299,7 +284,7 @@ class DBConfigService { ->set('auth_backend', $builder->createNamedParameter($newAuthBackend)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -325,7 +310,7 @@ class DBConfigService { ->set('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))) ->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))); - $query->execute(); + $query->executeStatement(); } } @@ -348,7 +333,7 @@ class DBConfigService { ->set('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))) ->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))); - $query->execute(); + $query->executeStatement(); } } @@ -377,11 +362,11 @@ class DBConfigService { $query = $query->andWhere($builder->expr()->eq('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))); } - $query->execute(); + $query->executeStatement(); } private function getMountsFromQuery(IQueryBuilder $query) { - $result = $query->execute(); + $result = $query->executeQuery(); $mounts = $result->fetchAll(); $uniqueMounts = []; foreach ($mounts as $mount) { @@ -432,7 +417,7 @@ class DBConfigService { ->from($table) ->where($builder->expr()->in('mount_id', $placeHolders)); - $result = $query->execute(); + $result = $query->executeQuery(); $rows = $result->fetchAll(); $result->closeCursor(); diff --git a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php index 44b473ac64d..ca4c82c03d7 100644 --- a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php +++ b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php @@ -36,7 +36,7 @@ class FederatedSharesDiscoverJob extends TimedJob { $qb->selectDistinct('remote') ->from('share_external'); - $result = $qb->execute(); + $result = $qb->executeQuery(); while ($row = $result->fetch()) { $this->discoveryService->discover($row['remote'], 'FEDERATED_SHARING', true); try { diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index 420de6889bf..6a5a55abed2 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -32,39 +32,23 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint */ protected $storage = null; - /** - * @var \OC\Files\View - */ - private $recipientView; - - private IUser $user; - /** @var \OCP\Share\IShare */ private $superShare; /** @var \OCP\Share\IShare[] */ private $groupedShares; - private IEventDispatcher $eventDispatcher; - - private ICache $cache; - public function __construct( $storage, array $mountpoints, $arguments, IStorageFactory $loader, - View $recipientView, + private View $recipientView, CappedMemoryCache $folderExistCache, - IEventDispatcher $eventDispatcher, - IUser $user, - ICache $cache, + private IEventDispatcher $eventDispatcher, + private IUser $user, + private ICache $cache, ) { - $this->user = $user; - $this->recipientView = $recipientView; - $this->eventDispatcher = $eventDispatcher; - $this->cache = $cache; - $this->superShare = $arguments['superShare']; $this->groupedShares = $arguments['groupedShares']; @@ -271,7 +255,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint ->from('filecache') ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId()))); - $result = $query->execute(); + $result = $query->executeQuery(); $row = $result->fetch(); $result->closeCursor(); if ($row) { diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php index a8f0cf84d76..673789f946b 100644 --- a/apps/user_ldap/lib/Mapping/AbstractMapping.php +++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php @@ -435,7 +435,7 @@ abstract class AbstractMapping { $query = $this->dbc->getQueryBuilder(); $query->select($query->func()->count('ldap_dn_hash')) ->from($this->getTableName()); - $res = $query->execute(); + $res = $query->executeQuery(); $count = $res->fetchOne(); $res->closeCursor(); return (int)$count; @@ -446,7 +446,7 @@ abstract class AbstractMapping { $query->select($query->func()->count('ldap_dn_hash')) ->from($this->getTableName()) ->where($query->expr()->like('directory_uuid', $query->createNamedParameter('invalidated_%'))); - $res = $query->execute(); + $res = $query->executeQuery(); $count = $res->fetchOne(); $res->closeCursor(); return (int)$count; diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index f03f84a33c0..7d14fc83449 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -99,7 +99,7 @@ class Manager implements IManager { ->where($query->expr()->neq('events', $query->createNamedParameter('[]'), IQueryBuilder::PARAM_STR)) ->groupBy('class', 'entity', $query->expr()->castColumn('events', IQueryBuilder::PARAM_STR)); - $result = $query->execute(); + $result = $query->executeQuery(); $operations = []; while ($row = $result->fetch()) { $eventNames = \json_decode($row['events']); @@ -145,7 +145,7 @@ class Manager implements IManager { ->where($query->expr()->eq('o.class', $query->createParameter('operationClass'))); $query->setParameters(['operationClass' => $operationClass]); - $result = $query->execute(); + $result = $query->executeQuery(); $scopesByOperation[$operationClass] = []; while ($row = $result->fetch()) { @@ -180,7 +180,7 @@ class Manager implements IManager { } $query->setParameters(['scope' => $scopeContext->getScope(), 'scopeId' => $scopeContext->getScopeId()]); - $result = $query->execute(); + $result = $query->executeQuery(); $this->operations[$scopeContext->getHash()] = []; while ($row = $result->fetch()) { @@ -221,7 +221,7 @@ class Manager implements IManager { $query->select('*') ->from('flow_operations') ->where($query->expr()->eq('id', $query->createNamedParameter($id))); - $result = $query->execute(); + $result = $query->executeQuery(); $row = $result->fetch(); $result->closeCursor(); @@ -250,7 +250,7 @@ class Manager implements IManager { 'entity' => $query->createNamedParameter($entity), 'events' => $query->createNamedParameter(json_encode($events)) ]); - $query->execute(); + $query->executeStatement(); $this->cacheFactory->createDistributed('flow')->remove('events'); @@ -313,7 +313,7 @@ class Manager implements IManager { } $qb->setParameters(['scope' => $scopeContext->getScope(), 'scopeId' => $scopeContext->getScopeId()]); - $result = $qb->execute(); + $result = $qb->executeQuery(); $operations = []; while (($opId = $result->fetchOne()) !== false) { @@ -393,12 +393,12 @@ class Manager implements IManager { $this->connection->beginTransaction(); $result = (bool)$query->delete('flow_operations') ->where($query->expr()->eq('id', $query->createNamedParameter($id))) - ->execute(); + ->executeStatement(); if ($result) { $qb = $this->connection->getQueryBuilder(); $result &= (bool)$qb->delete('flow_operations_scope') ->where($qb->expr()->eq('operation_id', $qb->createNamedParameter($id))) - ->execute(); + ->executeStatement(); } $this->connection->commit(); } catch (Exception $e) { @@ -537,7 +537,7 @@ class Manager implements IManager { $query->select('*') ->from('flow_checks') ->where($query->expr()->in('id', $query->createNamedParameter($checkIds, IQueryBuilder::PARAM_INT_ARRAY))); - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $this->checks[(int)$row['id']] = $row; @@ -568,7 +568,7 @@ class Manager implements IManager { $query->select('id') ->from('flow_checks') ->where($query->expr()->eq('hash', $query->createNamedParameter($hash))); - $result = $query->execute(); + $result = $query->executeQuery(); if ($row = $result->fetch()) { $result->closeCursor(); @@ -583,7 +583,7 @@ class Manager implements IManager { 'value' => $query->createNamedParameter($value), 'hash' => $query->createNamedParameter($hash), ]); - $query->execute(); + $query->executeStatement(); return $query->getLastInsertId(); } @@ -597,7 +597,7 @@ class Manager implements IManager { 'type' => $query->createNamedParameter($scope->getScope()), 'value' => $query->createNamedParameter($scope->getScopeId()), ]); - $insertQuery->execute(); + $insertQuery->executeStatement(); } public function formatOperation(array $operation): array { diff --git a/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php b/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php index 0bc380f8fc6..633d946cd7e 100644 --- a/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php +++ b/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php @@ -16,11 +16,9 @@ use OCP\WorkflowEngine\IManager; class PopulateNewlyIntroducedDatabaseFields implements IRepairStep { - /** @var IDBConnection */ - private $dbc; - - public function __construct(IDBConnection $dbc) { - $this->dbc = $dbc; + public function __construct( + private IDBConnection $dbc, + ) { } public function getName() { @@ -41,7 +39,7 @@ class PopulateNewlyIntroducedDatabaseFields implements IRepairStep { $insertQuery = $qb->insert('flow_operations_scope'); while (($id = $ids->fetchOne()) !== false) { $insertQuery->values(['operation_id' => $qb->createNamedParameter($id), 'type' => IManager::SCOPE_ADMIN]); - $insertQuery->execute(); + $insertQuery->executeStatement(); } } @@ -55,7 +53,7 @@ class PopulateNewlyIntroducedDatabaseFields implements IRepairStep { // in case the repair step is executed multiple times for whatever reason. /** @var IResult $result */ - $result = $selectQuery->execute(); + $result = $selectQuery->executeQuery(); return $result; } } |