diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2024-10-17 15:42:21 +0200 |
---|---|---|
committer | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2024-10-17 20:30:47 +0200 |
commit | a1681b0756ef784ef7056a3aae3e569a6dcae00e (patch) | |
tree | 13ad313771c95cfba750ca3f21048341c0e75105 /lib | |
parent | 40fd76f69e601ab5579e8ce9b81318d3924dd463 (diff) | |
download | nextcloud-server-a1681b0756ef784ef7056a3aae3e569a6dcae00e.tar.gz nextcloud-server-a1681b0756ef784ef7056a3aae3e569a6dcae00e.zip |
chore(db): Apply query prepared statementsdbQueriesExecStmt2
Fix: psalm
fix: bad file
fix: bug
chore: add batch
chore: add batch
chore: add batch
fix: psalm
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php | 4 | ||||
-rw-r--r-- | lib/private/Collaboration/Resources/Collection.php | 6 | ||||
-rw-r--r-- | lib/private/DirectEditing/Manager.php | 41 | ||||
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 42 | ||||
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Cache/Storage.php | 8 | ||||
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 36 | ||||
-rw-r--r-- | lib/private/Repair/CleanTags.php | 18 | ||||
-rw-r--r-- | lib/private/Repair/RepairDavShares.php | 20 | ||||
-rw-r--r-- | lib/private/Security/CredentialsManager.php | 6 | ||||
-rw-r--r-- | lib/private/Setup/PostgreSQL.php | 4 | ||||
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 61 | ||||
-rw-r--r-- | lib/private/SystemTag/SystemTagObjectMapper.php | 6 | ||||
-rw-r--r-- | lib/private/User/Database.php | 16 |
14 files changed, 116 insertions, 156 deletions
diff --git a/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php index cdbd8b48cf2..cc468dbeba0 100644 --- a/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php +++ b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php @@ -37,7 +37,7 @@ class ProviderUserAssignmentDao { $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 @@ class ProviderUserAssignmentDao { $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 d652305016f..cf5f7740ced 100644 --- a/lib/private/Collaboration/Resources/Collection.php +++ b/lib/private/Collaboration/Resources/Collection.php @@ -54,7 +54,7 @@ class Collection implements ICollection { $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 @@ class Collection implements ICollection { ->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 @@ class Collection implements ICollection { $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 7503ad94258..4823b6b4456 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 @@ class Manager implements IManager { $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 @@ class Manager implements IManager { $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 @@ class Manager implements IManager { $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 @@ class Manager implements IManager { $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 @@ class Manager implements IManager { ->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 @@ class Manager implements IManager { 'share_id' => $query->createNamedParameter($share !== null ? $share->getId(): null), 'timestamp' => $query->createNamedParameter(time()) ]); - $query->execute(); + $query->executeStatement(); return $token; } @@ -303,7 +288,7 @@ class Manager implements IManager { $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 9a6f7d41faa..f5baddb8590 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -74,7 +74,7 @@ class Cache implements ICache { $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 @@ class Cache implements ICache { } $query->whereStorageId($this->getNumericStorageId()); - $result = $query->execute(); + $result = $query->executeQuery(); $data = $result->fetch(); $result->closeCursor(); @@ -205,7 +205,7 @@ class Cache implements ICache { $metadataQuery = $query->selectMetadata(); - $result = $query->execute(); + $result = $query->executeQuery(); $files = $result->fetchAll(); $result->closeCursor(); @@ -294,7 +294,7 @@ class Cache implements ICache { 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 @@ class Cache implements ICache { $query->set($key, $query->createNamedParameter($value)); } - $query->execute(); + $query->executeStatement(); } if (count($extensionValues)) { @@ -386,7 +386,7 @@ class Cache implements ICache { $query->set($key, $query->createNamedParameter($value)); } - $query->execute(); + $query->executeStatement(); } } @@ -468,7 +468,7 @@ class Cache implements ICache { ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); - $result = $query->execute(); + $result = $query->executeQuery(); $id = $result->fetchOne(); $result->closeCursor(); @@ -523,13 +523,13 @@ class Cache implements ICache { $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 @@ class Cache implements ICache { 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 @@ class Cache implements ICache { 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 @@ class Cache implements ICache { $query->set('encrypted', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)); } - $query->execute(); + $query->executeStatement(); $this->connection->commit(); @@ -800,12 +800,12 @@ class Cache implements ICache { $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 @@ class Cache implements ICache { ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); - $result = $query->execute(); + $result = $query->executeQuery(); $size = $result->fetchOne(); $result->closeCursor(); @@ -919,7 +919,7 @@ class Cache implements ICache { ->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 @@ class Cache implements ICache { $query->andWhere($query->expr()->gte('size', $query->createNamedParameter(0))); } - $result = $query->execute(); + $result = $query->executeQuery(); $rows = $result->fetchAll(); $result->closeCursor(); @@ -1039,7 +1039,7 @@ class Cache implements ICache { ->from('filecache') ->whereStorageId($this->getNumericStorageId()); - $result = $query->execute(); + $result = $query->executeQuery(); $files = $result->fetchAll(\PDO::FETCH_COLUMN); $result->closeCursor(); @@ -1070,7 +1070,7 @@ class Cache implements ICache { ->orderBy('fileid', 'DESC') ->setMaxResults(1); - $result = $query->execute(); + $result = $query->executeQuery(); $id = $result->fetchOne(); $result->closeCursor(); @@ -1095,7 +1095,7 @@ class Cache implements ICache { ->whereStorageId($this->getNumericStorageId()) ->whereFileId($id); - $result = $query->execute(); + $result = $query->executeQuery(); $path = $result->fetchOne(); $result->closeCursor(); @@ -1121,7 +1121,7 @@ class Cache implements ICache { ->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 a4d118f8848..ff2d6766893 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -88,7 +88,7 @@ class QuerySearchHelper { $this->applySearchConstraints($query, $searchQuery, $caches); - $result = $query->execute(); + $result = $query->executeQuery(); $tags = $result->fetchAll(); $result->closeCursor(); return $tags; @@ -167,7 +167,7 @@ class QuerySearchHelper { $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 8d99a268dc0..2b49e65f0b4 100644 --- a/lib/private/Files/Cache/Storage.php +++ b/lib/private/Files/Cache/Storage.php @@ -149,7 +149,7 @@ class Storage { 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 @@ class Storage { ->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 @@ class Storage { $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 ad8061b1a8c..7d9ecc16f76 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -24,8 +24,6 @@ use Psr\Log\LoggerInterface; * 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<string> **/ private CappedMemoryCache $internalPathCache; - private LoggerInterface $logger; /** @var CappedMemoryCache<array> */ 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 @@ class UserMountCache implements IUserMountCache { ->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 @@ class UserMountCache implements IUserMountCache { ->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 @@ class UserMountCache implements IUserMountCache { ->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 @@ class UserMountCache implements IUserMountCache { $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 @@ class UserMountCache implements IUserMountCache { ->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 @@ class UserMountCache implements IUserMountCache { ->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 @@ class UserMountCache implements IUserMountCache { $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 @@ class UserMountCache implements IUserMountCache { $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 @@ class UserMountCache implements IUserMountCache { $query = $builder->delete('mounts') ->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -438,7 +430,7 @@ class UserMountCache implements IUserMountCache { ->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 258808cb28a..ad8fa6235e6 100644 --- a/lib/private/Repair/CleanTags.php +++ b/lib/private/Repair/CleanTags.php @@ -19,11 +19,6 @@ use OCP\Migration\IRepairStep; * @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 @@ class CleanTags implements IRepairStep { ->orderBy('uid') ->setMaxResults(50) ->setFirstResult($offset); - $result = $query->execute(); + $result = $query->executeQuery(); $users = []; $hadResults = false; @@ -94,7 +90,7 @@ class CleanTags implements IRepairStep { $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 @@ class CleanTags implements IRepairStep { ->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 36e3c397a39..557e2c080ca 100644 --- a/lib/private/Repair/RepairDavShares.php +++ b/lib/private/Repair/RepairDavShares.php @@ -23,27 +23,15 @@ use function urlencode; 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 fdf2c46ecf8..254984261d2 100644 --- a/lib/private/Security/CredentialsManager.php +++ b/lib/private/Security/CredentialsManager.php @@ -60,7 +60,7 @@ class CredentialsManager implements ICredentialsManager { $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($userId))); } - $qResult = $qb->execute(); + $qResult = $qb->executeQuery(); $result = $qResult->fetch(); $qResult->closeCursor(); @@ -89,7 +89,7 @@ class CredentialsManager implements ICredentialsManager { $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($userId))); } - return $qb->execute(); + return $qb->executeStatement(); } /** @@ -102,6 +102,6 @@ class CredentialsManager implements ICredentialsManager { $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 73f2dfe0623..b1cf031e876 100644 --- a/lib/private/Setup/PostgreSQL.php +++ b/lib/private/Setup/PostgreSQL.php @@ -131,7 +131,7 @@ class PostgreSQL extends AbstractDatabase { $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 @@ class PostgreSQL extends AbstractDatabase { $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 af993b7f314..2ad926fbaa7 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -226,7 +226,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ->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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ->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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ->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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ->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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ->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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv )) ->orderBy('id'); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); while ($data = $cursor->fetch()) { $children[] = $this->createShare($data); } @@ -416,7 +416,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))); } - $qb->execute(); + $qb->executeStatement(); } /** @@ -453,7 +453,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv '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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ->where( $qb->expr()->eq('id', $qb->createNamedParameter($share->getId())) ); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $data = $cursor->fetch(); $cursor->closeCursor(); @@ -541,7 +541,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)) ); - $qb->execute(); + $qb->executeStatement(); return $this->getShareById($share->getId(), $recipient); } @@ -556,7 +556,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->setMaxResults(1) - ->execute(); + ->executeQuery(); $data = $stmt->fetch(); $stmt->closeCursor(); @@ -596,14 +596,14 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv '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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); - $cursor = $qb->execute(); + $cursor = $qb->executeQuery(); $data = $cursor->fetch(); $cursor->closeCursor(); @@ -805,7 +805,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv return; } - $qb->execute(); + $qb->executeStatement(); } /** @@ -1198,7 +1197,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ->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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv foreach ($chunks as $chunk) { $qb->setParameter('parents', $chunk, IQueryBuilder::PARAM_INT_ARRAY); - $qb->execute(); + $qb->executeStatement(); } } @@ -1226,7 +1225,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv $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 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv ) ); - $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 157948e6e0c..18aae087714 100644 --- a/lib/private/SystemTag/SystemTagObjectMapper.php +++ b/lib/private/SystemTag/SystemTagObjectMapper.php @@ -97,7 +97,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { $objectIds = []; - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $objectIds[] = $row['objectid']; } @@ -187,7 +187,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { ->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 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { ->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 2d3808e9dc7..d2ec835a25d 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -97,7 +97,7 @@ class Database extends ABackend implements $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 @@ class Database extends ABackend implements $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 @@ class Database extends ABackend implements $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 @@ class Database extends ABackend implements 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 @@ class Database extends ABackend implements $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 @@ class Database extends ABackend implements ->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 @@ class Database extends ABackend implements 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 @@ class Database extends ABackend implements 'uid_lower', $qb->createNamedParameter(mb_strtolower($uid)) ) ); - $result = $qb->execute(); + $result = $qb->executeQuery(); $row = $result->fetch(); $result->closeCursor(); |