diff --git a/apps/dav/lib/CalDAV/Reminder/Backend.php b/apps/dav/lib/CalDAV/Reminder/Backend.php index f5608760b61fd..329af3a2f56aa 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, + protected ITimeFactory $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/Command/RemoveInvalidShares.php b/apps/dav/lib/Command/RemoveInvalidShares.php index 18f8de5b4e232..340e878a91288 100644 --- a/apps/dav/lib/Command/RemoveInvalidShares.php +++ b/apps/dav/lib/Command/RemoveInvalidShares.php @@ -38,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $query = $this->connection->getQueryBuilder(); $result = $query->selectDistinct('principaluri') ->from('dav_shares') - ->execute(); + ->executeQuery(); while ($row = $result->fetch()) { $principaluri = $row['principaluri']; @@ -59,6 +59,6 @@ private function deleteSharesForPrincipal($principaluri): void { $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 05deffdca9473..4fedac35b7296 100644 --- a/apps/dav/lib/Db/DirectMapper.php +++ b/apps/dav/lib/Db/DirectMapper.php @@ -45,6 +45,6 @@ public function deleteExpired(int $expiration) { $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 c7f57dcb11718..ecc462e153b00 100644 --- a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php +++ b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php @@ -15,18 +15,11 @@ 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 @@ protected function getInvalidObjects($pattern) { $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 @@ protected function getInvalidObjects($pattern) { ->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 @@ protected function getInvalidObjects($pattern) { 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 d22e4b82c9fea..6833ca2ffa6d6 100644 --- a/apps/dav/lib/Migration/FixBirthdayCalendarComponent.php +++ b/apps/dav/lib/Migration/FixBirthdayCalendarComponent.php @@ -1,4 +1,5 @@ connection = $connection; + public function __construct( + private IDBConnection $connection, + ) { } /** @@ -39,7 +33,7 @@ public function run(IOutput $output) { $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 793b55166404d..cd4b8b31f4d4f 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, + ) { } /** 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/dav/lib/Migration/RemoveOrphanEventsAndContacts.php b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php index 798fbad40183b..ead2645779bb8 100644 --- a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php +++ b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php @@ -16,11 +16,9 @@ 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 @@ protected function removeOrphanChildren($childTable, $parentTable, $parentId): i $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 @@ protected function removeOrphanChildren($childTable, $parentTable, $parentId): i $orphanItemsBatch = array_chunk($orphanItems, 200); foreach ($orphanItemsBatch as $items) { $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY); - $qb->execute(); + $qb->executeStatement(); } } diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 64e8b0e4fa50b..f78112e2ce6c9 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -450,7 +450,7 @@ private function unshare($id, array $notification) { ) ); - $result = $qb->execute(); + $result = $qb->executeQuery(); $share = $result->fetch(); $result->closeCursor(); @@ -470,13 +470,13 @@ private function unshare($id, array $notification) { ) ); - $qb->execute(); + $qb->executeStatement(); // delete all child in case of a group share $qb = $this->connection->getQueryBuilder(); $qb->delete('share_external') ->where($qb->expr()->eq('parent', $qb->createNamedParameter((int)$share['id']))); - $qb->execute(); + $qb->executeStatement(); $ownerDisplayName = $this->getUserDisplayName($owner->getId()); @@ -624,7 +624,7 @@ protected function updatePermissionsInDatabase(IShare $share, $permissions) { $query->update('share') ->where($query->expr()->eq('id', $query->createNamedParameter($share->getId()))) ->set('permissions', $query->createNamedParameter($permissions)) - ->execute(); + ->executeStatement(); } diff --git a/apps/files_sharing/lib/Migration/SetAcceptedStatus.php b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php index 43a3c4aad740e..4da6aad4b3308 100644 --- a/apps/files_sharing/lib/Migration/SetAcceptedStatus.php +++ b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php @@ -17,16 +17,10 @@ class SetAcceptedStatus implements IRepairStep { - /** @var IDBConnection */ - private $connection; - - /** @var IConfig */ - private $config; - - - public function __construct(IDBConnection $connection, IConfig $config) { - $this->connection = $connection; - $this->config = $config; + public function __construct( + private IDBConnection $connection, + private IConfig $config, + ) { } /** @@ -52,7 +46,7 @@ public function run(IOutput $output): void { ->update('share') ->set('accepted', $query->createNamedParameter(IShare::STATUS_ACCEPTED)) ->where($query->expr()->in('share_type', $query->createNamedParameter([IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_USERGROUP], IQueryBuilder::PARAM_INT_ARRAY))); - $query->execute(); + $query->executeStatement(); } protected function shouldRun() { diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index 0b7ec58aef33d..56a4aa47e604c 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -1,4 +1,5 @@ federatedShareProvider = $federatedShareProvider; } else { @@ -189,7 +189,7 @@ protected static function resolveReshares($source) { ->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/files_trashbin/lib/Command/CleanUp.php b/apps/files_trashbin/lib/Command/CleanUp.php index 007e97123bfa8..daaa4003f7aed 100644 --- a/apps/files_trashbin/lib/Command/CleanUp.php +++ b/apps/files_trashbin/lib/Command/CleanUp.php @@ -1,4 +1,5 @@ userManager = $userManager; - $this->rootFolder = $rootFolder; - $this->dbConnection = $dbConnection; } protected function configure() { @@ -119,7 +107,7 @@ protected function removeDeletedFiles(string $uid, OutputInterface $output, bool $query->delete('files_trash') ->where($query->expr()->eq('user', $query->createParameter('uid'))) ->setParameter('uid', $uid); - $query->execute(); + $query->executeStatement(); } else { if ($verbose) { $output->writeln("No trash found for $uid"); diff --git a/apps/oauth2/lib/Migration/SetTokenExpiration.php b/apps/oauth2/lib/Migration/SetTokenExpiration.php index 5077e74be873b..51b1061ae113c 100644 --- a/apps/oauth2/lib/Migration/SetTokenExpiration.php +++ b/apps/oauth2/lib/Migration/SetTokenExpiration.php @@ -18,21 +18,15 @@ class SetTokenExpiration implements IRepairStep { - /** @var IDBConnection */ - private $connection; - /** @var ITimeFactory */ private $time; - /** @var TokenProvider */ - private $tokenProvider; - - public function __construct(IDBConnection $connection, + public function __construct( + private IDBConnection $connection, ITimeFactory $timeFactory, - TokenProvider $tokenProvider) { - $this->connection = $connection; + private TokenProvider $tokenProvider, + ) { $this->time = $timeFactory; - $this->tokenProvider = $tokenProvider; } public function getName(): string { @@ -44,7 +38,7 @@ public function run(IOutput $output) { $qb->select('*') ->from('oauth2_access_tokens'); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($row = $cursor->fetch()) { $token = AccessToken::fromRow($row); diff --git a/apps/user_ldap/lib/Migration/RemoveRefreshTime.php b/apps/user_ldap/lib/Migration/RemoveRefreshTime.php index fd414e7e4b7ae..88ac56ccb8445 100644 --- a/apps/user_ldap/lib/Migration/RemoveRefreshTime.php +++ b/apps/user_ldap/lib/Migration/RemoveRefreshTime.php @@ -22,14 +22,10 @@ */ class RemoveRefreshTime implements IRepairStep { - /** @var IDBConnection */ - private $dbc; - /** @var IConfig */ - private $config; - - public function __construct(IDBConnection $dbc, IConfig $config) { - $this->dbc = $dbc; - $this->config = $config; + public function __construct( + private IDBConnection $dbc, + private IConfig $config, + ) { } public function getName() { @@ -43,6 +39,6 @@ public function run(IOutput $output) { $qb->delete('preferences') ->where($qb->expr()->eq('appid', $qb->createNamedParameter('user_ldap'))) ->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lastFeatureRefresh'))) - ->execute(); + ->executeStatement(); } } 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/build/psalm-baseline.xml b/build/psalm-baseline.xml index 22ecf47ec8e3d..c83074709ce06 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -1792,12 +1792,8 @@ - - execute()]]> - - @@ -2466,16 +2462,6 @@ value)]]> - - - execute()]]> - execute()]]> - - - - - - diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index 43b2d62a90013..b26494417ec1a 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -298,7 +298,7 @@ protected function copyTable(Connection $fromDB, Connection $toDB, Table $table, $query->automaticTablePrefix(false); $query->select($query->func()->count('*', 'num_entries')) ->from($table->getName()); - $result = $query->execute(); + $result = $query->executeQuery(); $count = $result->fetchOne(); $result->closeCursor(); @@ -337,7 +337,7 @@ protected function copyTable(Connection $fromDB, Connection $toDB, Table $table, for ($chunk = 0; $chunk < $numChunks; $chunk++) { $query->setFirstResult($chunk * $chunkSize); - $result = $query->execute(); + $result = $query->executeQuery(); try { $toDB->beginTransaction(); 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/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php index cdbd8b48cf209..cc468dbeba024 100644 --- a/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php +++ b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php @@ -37,7 +37,7 @@ public function getState(string $uid): array { $query = $qb->select('provider_id', 'enabled') ->from(self::TABLE_NAME) ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))); - $result = $query->execute(); + $result = $query->executeQuery(); $providers = []; foreach ($result->fetchAll() as $row) { $providers[(string)$row['provider_id']] = (int)$row['enabled'] === 1; @@ -106,6 +106,6 @@ public function deleteAll(string $providerId): void { $deleteQuery = $qb->delete(self::TABLE_NAME) ->where($qb->expr()->eq('provider_id', $qb->createNamedParameter($providerId))); - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } } diff --git a/lib/private/Collaboration/Resources/Collection.php b/lib/private/Collaboration/Resources/Collection.php index d652305016fc3..cf5f7740ced94 100644 --- a/lib/private/Collaboration/Resources/Collection.php +++ b/lib/private/Collaboration/Resources/Collection.php @@ -54,7 +54,7 @@ public function setName(string $name): void { $query->update(Manager::TABLE_COLLECTIONS) ->set('name', $query->createNamedParameter($name)) ->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $this->name = $name; } @@ -118,7 +118,7 @@ public function removeResource(IResource $resource): void { ->where($query->expr()->eq('collection_id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT))) ->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType()))) ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId()))); - $query->execute(); + $query->executeStatement(); if (empty($this->resources)) { $this->removeCollection(); @@ -172,7 +172,7 @@ protected function removeCollection(): void { $query = $this->connection->getQueryBuilder(); $query->delete(Manager::TABLE_COLLECTIONS) ->where($query->expr()->eq('id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $this->manager->invalidateAccessCacheForCollection($this); $this->id = 0; diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php index 7503ad9425890..4823b6b4456fd 100644 --- a/lib/private/DirectEditing/Manager.php +++ b/lib/private/DirectEditing/Manager.php @@ -38,36 +38,21 @@ class Manager implements IManager { /** @var IEditor[] */ private $editors = []; - /** @var IDBConnection */ - private $connection; - /** @var IUserSession */ - private $userSession; - /** @var ISecureRandom */ - private $random; /** @var string|null */ private $userId; - /** @var IRootFolder */ - private $rootFolder; /** @var IL10N */ private $l10n; - /** @var EncryptionManager */ - private $encryptionManager; public function __construct( - ISecureRandom $random, - IDBConnection $connection, - IUserSession $userSession, - IRootFolder $rootFolder, - IFactory $l10nFactory, - EncryptionManager $encryptionManager, + private ISecureRandom $random, + private IDBConnection $connection, + private IUserSession $userSession, + private IRootFolder $rootFolder, + private IFactory $l10nFactory, + private EncryptionManager $encryptionManager, ) { - $this->random = $random; - $this->connection = $connection; - $this->userSession = $userSession; $this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null; - $this->rootFolder = $rootFolder; $this->l10n = $l10nFactory->get('lib'); - $this->encryptionManager = $encryptionManager; } public function registerDirectEditor(IEditor $directEditor): void { @@ -209,7 +194,7 @@ public function getToken(string $token): IToken { $query = $this->connection->getQueryBuilder(); $query->select('*')->from(self::TABLE_TOKENS) ->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR))); - $result = $query->execute(); + $result = $query->executeQuery(); if ($tokenRow = $result->fetch(FetchMode::ASSOCIATIVE)) { return new Token($this, $tokenRow); } @@ -220,7 +205,7 @@ public function cleanup(): int { $query = $this->connection->getQueryBuilder(); $query->delete(self::TABLE_TOKENS) ->where($query->expr()->lt('timestamp', $query->createNamedParameter(time() - self::TOKEN_CLEANUP_TIME))); - return $query->execute(); + return $query->executeStatement(); } public function refreshToken(string $token): bool { @@ -228,7 +213,7 @@ public function refreshToken(string $token): bool { $query->update(self::TABLE_TOKENS) ->set('timestamp', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT)) ->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR))); - $result = $query->execute(); + $result = $query->executeStatement(); return $result !== 0; } @@ -237,7 +222,7 @@ public function invalidateToken(string $token): bool { $query = $this->connection->getQueryBuilder(); $query->delete(self::TABLE_TOKENS) ->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR))); - $result = $query->execute(); + $result = $query->executeStatement(); return $result !== 0; } @@ -247,7 +232,7 @@ public function accessToken(string $token): bool { ->set('accessed', $query->createNamedParameter(true, IQueryBuilder::PARAM_BOOL)) ->set('timestamp', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT)) ->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR))); - $result = $query->execute(); + $result = $query->executeStatement(); return $result !== 0; } @@ -272,7 +257,7 @@ public function createToken($editorId, File $file, string $filePath, ?IShare $sh 'share_id' => $query->createNamedParameter($share !== null ? $share->getId(): null), 'timestamp' => $query->createNamedParameter(time()) ]); - $query->execute(); + $query->executeStatement(); return $token; } @@ -303,7 +288,7 @@ public function isEnabled(): bool { $moduleId = $this->encryptionManager->getDefaultEncryptionModuleId(); $module = $this->encryptionManager->getEncryptionModule($moduleId); /** @var \OCA\Encryption\Util $util */ - $util = \OC::$server->get(\OCA\Encryption\Util::class); + $util = \OCP\Server::get(\OCA\Encryption\Util::class); if ($module->isReadyForUser($this->userId) && $util->isMasterKeyEnabled()) { return true; } diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 9a6f7d41faa22..f5baddb8590d0 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -74,7 +74,7 @@ public function __construct( $this->storageId = md5($this->storageId); } if (!$dependencies) { - $dependencies = \OC::$server->get(CacheDependencies::class); + $dependencies = \OCP\Server::get(CacheDependencies::class); } $this->storageCache = new Storage($this->storage, true, $dependencies->getConnection()); $this->mimetypeLoader = $dependencies->getMimeTypeLoader(); @@ -127,7 +127,7 @@ public function get($file) { } $query->whereStorageId($this->getNumericStorageId()); - $result = $query->execute(); + $result = $query->executeQuery(); $data = $result->fetch(); $result->closeCursor(); @@ -205,7 +205,7 @@ public function getFolderContentsById($fileId) { $metadataQuery = $query->selectMetadata(); - $result = $query->execute(); + $result = $query->executeQuery(); $files = $result->fetchAll(); $result->closeCursor(); @@ -294,7 +294,7 @@ public function insert($file, array $data) { foreach ($extensionValues as $column => $value) { $query->setValue($column, $query->createNamedParameter($value)); } - $query->execute(); + $query->executeStatement(); } $event = new CacheEntryInsertedEvent($this->storage, $file, $fileId, $storageId); @@ -355,7 +355,7 @@ public function update($id, array $data) { $query->set($key, $query->createNamedParameter($value)); } - $query->execute(); + $query->executeStatement(); } if (count($extensionValues)) { @@ -386,7 +386,7 @@ public function update($id, array $data) { $query->set($key, $query->createNamedParameter($value)); } - $query->execute(); + $query->executeStatement(); } } @@ -468,7 +468,7 @@ public function getId($file) { ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); - $result = $query->execute(); + $result = $query->executeQuery(); $id = $result->fetchOne(); $result->closeCursor(); @@ -523,13 +523,13 @@ public function remove($file) { $query->delete('filecache') ->whereStorageId($this->getNumericStorageId()) ->whereFileId($entry->getId()); - $query->execute(); + $query->executeStatement(); $query = $this->getQueryBuilder(); $query->delete('filecache_extended') ->whereFileId($entry->getId()) ->hintShardKey('storage', $this->getNumericStorageId()); - $query->execute(); + $query->executeStatement(); if ($entry->getMimeType() == FileInfo::MIMETYPE_FOLDER) { $this->removeChildren($entry); @@ -577,7 +577,7 @@ private function removeChildren(ICacheEntry $entry) { foreach (array_chunk($childIds, 1000) as $childIdChunk) { $query->setParameter('childIds', $childIdChunk, IQueryBuilder::PARAM_INT_ARRAY); - $query->execute(); + $query->executeStatement(); } /** @var ICacheEntry[] $childFolders */ @@ -603,7 +603,7 @@ private function removeChildren(ICacheEntry $entry) { sort($parentIds, SORT_NUMERIC); foreach (array_chunk($parentIds, 1000) as $parentIdChunk) { $query->setParameter('parentIds', $parentIdChunk, IQueryBuilder::PARAM_INT_ARRAY); - $query->execute(); + $query->executeStatement(); } foreach (array_combine($deletedIds, $deletedPaths) as $fileId => $filePath) { @@ -765,7 +765,7 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { $query->set('encrypted', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)); } - $query->execute(); + $query->executeStatement(); $this->connection->commit(); @@ -800,12 +800,12 @@ public function clear() { $query = $this->getQueryBuilder(); $query->delete('filecache') ->whereStorageId($this->getNumericStorageId()); - $query->execute(); + $query->executeStatement(); $query = $this->connection->getQueryBuilder(); $query->delete('storages') ->where($query->expr()->eq('id', $query->createNamedParameter($this->storageId))); - $query->execute(); + $query->executeStatement(); } /** @@ -830,7 +830,7 @@ public function getStatus($file) { ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); - $result = $query->execute(); + $result = $query->executeQuery(); $size = $result->fetchOne(); $result->closeCursor(); @@ -919,7 +919,7 @@ public function getIncompleteChildrenCount($fileId) { ->whereStorageId($this->getNumericStorageId()) ->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))); - $result = $query->execute(); + $result = $query->executeQuery(); $size = (int)$result->fetchOne(); $result->closeCursor(); @@ -965,7 +965,7 @@ protected function calculateFolderSizeInner(string $path, $entry = null, bool $i $query->andWhere($query->expr()->gte('size', $query->createNamedParameter(0))); } - $result = $query->execute(); + $result = $query->executeQuery(); $rows = $result->fetchAll(); $result->closeCursor(); @@ -1039,7 +1039,7 @@ public function getAll() { ->from('filecache') ->whereStorageId($this->getNumericStorageId()); - $result = $query->execute(); + $result = $query->executeQuery(); $files = $result->fetchAll(\PDO::FETCH_COLUMN); $result->closeCursor(); @@ -1070,7 +1070,7 @@ public function getIncomplete() { ->orderBy('fileid', 'DESC') ->setMaxResults(1); - $result = $query->execute(); + $result = $query->executeQuery(); $id = $result->fetchOne(); $result->closeCursor(); @@ -1095,7 +1095,7 @@ public function getPathById($id) { ->whereStorageId($this->getNumericStorageId()) ->whereFileId($id); - $result = $query->execute(); + $result = $query->executeQuery(); $path = $result->fetchOne(); $result->closeCursor(); @@ -1121,7 +1121,7 @@ public static function getById($id) { ->from('filecache') ->where($query->expr()->eq('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT))); - $result = $query->execute(); + $result = $query->executeQuery(); $row = $result->fetch(); $result->closeCursor(); diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index a4d118f88485b..ff2d67668939c 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -88,7 +88,7 @@ public function findUsedTagsInCaches(ISearchQuery $searchQuery, array $caches): $this->applySearchConstraints($query, $searchQuery, $caches); - $result = $query->execute(); + $result = $query->executeQuery(); $tags = $result->fetchAll(); $result->closeCursor(); return $tags; @@ -167,7 +167,7 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array $this->applySearchConstraints($query, $searchQuery, $caches, $metadataQuery); - $result = $query->execute(); + $result = $query->executeQuery(); $files = $result->fetchAll(); $rawEntries = array_map(function (array $data) use ($metadataQuery) { diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php index 8d99a268dc043..2b49e65f0b41c 100644 --- a/lib/private/Files/Cache/Storage.php +++ b/lib/private/Files/Cache/Storage.php @@ -149,7 +149,7 @@ 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(); @@ -157,7 +157,7 @@ public function setAvailability($isAvailable, int $delay = 0) { ->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(); } /** @@ -182,13 +182,13 @@ public static function remove($storageId) { $query = \OC::$server->getDatabaseConnection()->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->delete('filecache') ->where($query->expr()->eq('storage', $query->createNamedParameter($numericId))); - $query->execute(); + $query->executeStatement(); } } diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index ad8061b1a8cb4..7d9ecc16f76a5 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -24,8 +24,6 @@ * Cache mounts points per user in the cache so we can easily look them up */ class UserMountCache implements IUserMountCache { - private IDBConnection $connection; - private IUserManager $userManager; /** * Cached mount info. @@ -37,24 +35,18 @@ class UserMountCache implements IUserMountCache { * @var CappedMemoryCache **/ private CappedMemoryCache $internalPathCache; - private LoggerInterface $logger; /** @var CappedMemoryCache */ private CappedMemoryCache $cacheInfoCache; - private IEventLogger $eventLogger; /** * UserMountCache constructor. */ public function __construct( - IDBConnection $connection, - IUserManager $userManager, - LoggerInterface $logger, - IEventLogger $eventLogger, + private IDBConnection $connection, + private IUserManager $userManager, + private LoggerInterface $logger, + private IEventLogger $eventLogger, ) { - $this->connection = $connection; - $this->userManager = $userManager; - $this->logger = $logger; - $this->eventLogger = $eventLogger; $this->cacheInfoCache = new CappedMemoryCache(); $this->internalPathCache = new CappedMemoryCache(); $this->mountsForUsers = new CappedMemoryCache(); @@ -177,7 +169,7 @@ private function updateCachedMount(ICachedMountInfo $mount) { ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } private function removeFromCache(ICachedMountInfo $mount) { @@ -187,7 +179,7 @@ private function removeFromCache(ICachedMountInfo $mount) { ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))) ->andWhere($builder->expr()->eq('mount_point', $builder->createNamedParameter($mount->getMountPoint()))); - $query->execute(); + $query->executeStatement(); } /** @@ -239,7 +231,7 @@ public function getMountsForUser(IUser $user) { ->from('mounts', 'm') ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userUID))); - $result = $query->execute(); + $result = $query->executeQuery(); $rows = $result->fetchAll(); $result->closeCursor(); @@ -284,7 +276,7 @@ public function getMountsForStorageId($numericStorageId, $user = null) { $query->andWhere($builder->expr()->eq('user_id', $builder->createNamedParameter($user))); } - $result = $query->execute(); + $result = $query->executeQuery(); $rows = $result->fetchAll(); $result->closeCursor(); @@ -302,7 +294,7 @@ public function getMountsForRootId($rootFileId) { ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) ->where($builder->expr()->eq('root_id', $builder->createNamedParameter($rootFileId, IQueryBuilder::PARAM_INT))); - $result = $query->execute(); + $result = $query->executeQuery(); $rows = $result->fetchAll(); $result->closeCursor(); @@ -321,7 +313,7 @@ private function getCacheInfoFromFileId($fileId): array { ->from('filecache') ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT))); - $result = $query->execute(); + $result = $query->executeQuery(); $row = $result->fetch(); $result->closeCursor(); @@ -390,7 +382,7 @@ public function removeUserMounts(IUser $user) { $query = $builder->delete('mounts') ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID()))); - $query->execute(); + $query->executeStatement(); } public function removeUserStorageMount($storageId, $userId) { @@ -399,7 +391,7 @@ public function removeUserStorageMount($storageId, $userId) { $query = $builder->delete('mounts') ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userId))) ->andWhere($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } public function remoteStorageMounts($storageId) { @@ -407,7 +399,7 @@ public function remoteStorageMounts($storageId) { $query = $builder->delete('mounts') ->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -438,7 +430,7 @@ public function getUsedSpaceForUsers(array $users) { ->where($builder->expr()->eq('m.mount_point', $mountPoint)) ->andWhere($builder->expr()->in('m.user_id', $builder->createNamedParameter($userIds, IQueryBuilder::PARAM_STR_ARRAY))); - $result = $query->execute(); + $result = $query->executeQuery(); $results = []; while ($row = $result->fetch()) { diff --git a/lib/private/Repair/CleanTags.php b/lib/private/Repair/CleanTags.php index 258808cb28ab7..ad8fa6235e609 100644 --- a/lib/private/Repair/CleanTags.php +++ b/lib/private/Repair/CleanTags.php @@ -19,11 +19,6 @@ * @package OC\Repair */ class CleanTags implements IRepairStep { - /** @var IDBConnection */ - protected $connection; - - /** @var IUserManager */ - protected $userManager; protected $deletedTags = 0; @@ -31,9 +26,10 @@ class CleanTags implements IRepairStep { * @param IDBConnection $connection * @param IUserManager $userManager */ - public function __construct(IDBConnection $connection, IUserManager $userManager) { - $this->connection = $connection; - $this->userManager = $userManager; + public function __construct( + protected IDBConnection $connection, + protected IUserManager $userManager, + ) { } /** @@ -73,7 +69,7 @@ protected function checkTags($offset) { ->orderBy('uid') ->setMaxResults(50) ->setFirstResult($offset); - $result = $query->execute(); + $result = $query->executeQuery(); $users = []; $hadResults = false; @@ -94,7 +90,7 @@ protected function checkTags($offset) { $query = $this->connection->getQueryBuilder(); $query->delete('vcategory') ->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY))); - $this->deletedTags += $query->execute(); + $this->deletedTags += $query->executeStatement(); } return true; } @@ -162,7 +158,7 @@ protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTabl ->andWhere( $qb->expr()->isNull('s.' . $sourceNullColumn) ); - $result = $qb->execute(); + $result = $qb->executeQuery(); $orphanItems = []; while ($row = $result->fetch()) { diff --git a/lib/private/Repair/RepairDavShares.php b/lib/private/Repair/RepairDavShares.php index 36e3c397a3926..557e2c080ca73 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; } /** diff --git a/lib/private/Security/CredentialsManager.php b/lib/private/Security/CredentialsManager.php index fdf2c46ecf818..254984261d215 100644 --- a/lib/private/Security/CredentialsManager.php +++ b/lib/private/Security/CredentialsManager.php @@ -60,7 +60,7 @@ public function retrieve(string $userId, string $identifier): mixed { $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($userId))); } - $qResult = $qb->execute(); + $qResult = $qb->executeQuery(); $result = $qResult->fetch(); $qResult->closeCursor(); @@ -89,7 +89,7 @@ public function delete(string $userId, string $identifier): int { $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($userId))); } - return $qb->execute(); + return $qb->executeStatement(); } /** @@ -102,6 +102,6 @@ public function erase(string $userId): int { $qb->delete(self::DB_TABLE) ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) ; - return $qb->execute(); + return $qb->executeStatement(); } } diff --git a/lib/private/Setup/PostgreSQL.php b/lib/private/Setup/PostgreSQL.php index 73f2dfe062328..b1cf031e87635 100644 --- a/lib/private/Setup/PostgreSQL.php +++ b/lib/private/Setup/PostgreSQL.php @@ -131,7 +131,7 @@ private function userExists(Connection $connection) { $query = $builder->select('*') ->from('pg_roles') ->where($builder->expr()->eq('rolname', $builder->createNamedParameter($this->dbUser))); - $result = $query->execute(); + $result = $query->executeQuery(); return $result->rowCount() > 0; } @@ -141,7 +141,7 @@ private function databaseExists(Connection $connection) { $query = $builder->select('datname') ->from('pg_database') ->where($builder->expr()->eq('datname', $builder->createNamedParameter($this->dbName))); - $result = $query->execute(); + $result = $query->executeQuery(); return $result->rowCount() > 0; } 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(); diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 2d3808e9dc773..d2ec835a25d16 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -97,7 +97,7 @@ public function createUser(string $uid, string $password): bool { $qb->insert($this->table) ->values([ 'uid' => $qb->createNamedParameter($uid), - 'password' => $qb->createNamedParameter(\OC::$server->get(IHasher::class)->hash($password)), + 'password' => $qb->createNamedParameter(\OCP\Server::get(IHasher::class)->hash($password)), 'uid_lower' => $qb->createNamedParameter(mb_strtolower($uid)), ]); @@ -130,7 +130,7 @@ public function deleteUser($uid) { $query = $this->dbConn->getQueryBuilder(); $query->delete($this->table) ->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid)))); - $result = $query->execute(); + $result = $query->executeStatement(); if (isset($this->cache[$uid])) { unset($this->cache[$uid]); @@ -144,7 +144,7 @@ private function updatePassword(string $uid, string $passwordHash): bool { $query->update($this->table) ->set('password', $query->createNamedParameter($passwordHash)) ->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid)))); - $result = $query->execute(); + $result = $query->executeStatement(); return $result ? true : false; } @@ -164,7 +164,7 @@ public function setPassword(string $uid, string $password): bool { if ($this->userExists($uid)) { $this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password)); - $hasher = \OC::$server->get(IHasher::class); + $hasher = \OCP\Server::get(IHasher::class); $hashedPassword = $hasher->hash($password); $return = $this->updatePassword($uid, $hashedPassword); @@ -236,7 +236,7 @@ public function setDisplayName(string $uid, string $displayName): bool { $query->update($this->table) ->set('displayname', $query->createNamedParameter($displayName)) ->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid)))); - $query->execute(); + $query->executeStatement(); $this->cache[$uid]['displayname'] = $displayName; @@ -329,7 +329,7 @@ public function searchKnownUsersByDisplayName(string $searcher, string $pattern, ->setMaxResults($limit) ->setFirstResult($offset); - $result = $query->execute(); + $result = $query->executeQuery(); $displayNames = []; while ($row = $result->fetch()) { $displayNames[(string)$row['uid']] = (string)$row['displayname']; @@ -354,7 +354,7 @@ public function checkPassword(string $loginName, string $password) { if ($found && is_array($this->cache[$loginName])) { $storedHash = $this->cache[$loginName]['password']; $newHash = ''; - if (\OC::$server->get(IHasher::class)->verify($password, $storedHash, $newHash)) { + if (\OCP\Server::get(IHasher::class)->verify($password, $storedHash, $newHash)) { if (!empty($newHash)) { $this->updatePassword($loginName, $newHash); } @@ -390,7 +390,7 @@ private function loadUser($uid) { 'uid_lower', $qb->createNamedParameter(mb_strtolower($uid)) ) ); - $result = $qb->execute(); + $result = $qb->executeQuery(); $row = $result->fetch(); $result->closeCursor();