diff options
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 28 | ||||
-rw-r--r-- | apps/files/lib/Command/RepairTree.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/Service/DBConfigService.php | 32 | ||||
-rw-r--r-- | apps/files_sharing/lib/Migration/SetAcceptedStatus.php | 19 | ||||
-rw-r--r-- | build/psalm-baseline.xml | 8 | ||||
-rw-r--r-- | lib/private/Comments/Manager.php | 13 | ||||
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 81 | ||||
-rw-r--r-- | lib/private/Files/Cache/Storage.php | 6 | ||||
-rw-r--r-- | lib/private/Files/Type/Loader.php | 9 | ||||
-rw-r--r-- | lib/private/Repair/RepairDavShares.php | 24 | ||||
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 60 | ||||
-rw-r--r-- | lib/private/User/Database.php | 6 |
12 files changed, 136 insertions, 154 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index b94da9fa7ed..f7d0a888efd 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -200,7 +200,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $addressBooks = []; - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $addressBooks[$row['id']] = [ 'id' => $row['id'], @@ -395,7 +395,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { 'synctoken' => $query->createParameter('synctoken'), ]) ->setParameters($values) - ->execute(); + ->executeStatement(); $addressBookId = $query->getLastInsertId(); return [ @@ -479,7 +479,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $cards = []; - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $row['etag'] = '"' . $row['etag'] . '"'; @@ -516,7 +516,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri))) ->setMaxResults(1); - $result = $query->execute(); + $result = $query->executeQuery(); $row = $result->fetch(); if (!$row) { return false; @@ -560,7 +560,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { foreach ($chunks as $uris) { $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); - $result = $query->execute(); + $result = $query->executeQuery(); while ($row = $result->fetch()) { $row['etag'] = '"' . $row['etag'] . '"'; @@ -634,7 +634,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { 'etag' => $query->createNamedParameter($etag), 'uid' => $query->createNamedParameter($uid), ]) - ->execute(); + ->executeStatement(); $etagCacheKey = "$addressBookId#$cardUri"; $this->etagCache[$etagCacheKey] = $etag; @@ -697,7 +697,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->set('uid', $query->createNamedParameter($uid)) ->where($query->expr()->eq('uri', $query->createNamedParameter($cardUri))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))) - ->execute(); + ->executeStatement(); $this->etagCache[$etagCacheKey] = $etag; @@ -1165,7 +1165,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { */ } - $result = $query2->execute(); + $result = $query2->executeQuery(); $matches = $result->fetchAll(); $result->closeCursor(); $matches = array_map(function ($match) { @@ -1207,7 +1207,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->from($this->dbCardsPropertiesTable) ->where($query->expr()->eq('name', $query->createNamedParameter($name))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($bookId))) - ->execute(); + ->executeQuery(); $all = $result->fetchAll(PDO::FETCH_COLUMN); $result->closeCursor(); @@ -1227,7 +1227,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->where($query->expr()->eq('id', $query->createParameter('id'))) ->setParameter('id', $id); - $result = $query->execute(); + $result = $query->executeQuery(); $uri = $result->fetch(); $result->closeCursor(); @@ -1251,7 +1251,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $query->select('*')->from($this->dbCardsTable) ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); - $queryResult = $query->execute(); + $queryResult = $query->executeQuery(); $contact = $queryResult->fetch(); $queryResult->closeCursor(); @@ -1324,7 +1324,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $query->setParameter('name', $property->name); $query->setParameter('value', mb_strcut($property->getValue(), 0, 254)); $query->setParameter('preferred', $preferred); - $query->execute(); + $query->executeStatement(); } }, $this->db); } @@ -1350,7 +1350,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $query->delete($this->dbCardsPropertiesTable) ->where($query->expr()->eq('cardid', $query->createNamedParameter($cardId))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); - $query->execute(); + $query->executeStatement(); } /** @@ -1362,7 +1362,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); - $result = $query->execute(); + $result = $query->executeQuery(); $cardIds = $result->fetch(); $result->closeCursor(); diff --git a/apps/files/lib/Command/RepairTree.php b/apps/files/lib/Command/RepairTree.php index 622ccba48a3..222ff7db02e 100644 --- a/apps/files/lib/Command/RepairTree.php +++ b/apps/files/lib/Command/RepairTree.php @@ -60,7 +60,7 @@ class RepairTree extends Command { 'path' => $row['parent_path'] . '/' . $row['name'], 'storage' => $row['parent_storage'], ]); - $query->execute(); + $query->executeStatement(); } } } @@ -85,7 +85,7 @@ class RepairTree extends Command { $query = $this->connection->getQueryBuilder(); $query->delete('filecache') ->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId))); - $query->execute(); + $query->executeStatement(); } private function findBrokenTreeBits(): array { diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php index 6fb7e01271e..0d46f3f379f 100644 --- a/apps/files_external/lib/Service/DBConfigService.php +++ b/apps/files_external/lib/Service/DBConfigService.php @@ -112,7 +112,7 @@ class DBConfigService { ) ) ->groupBy(['a.mount_id']); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); $result = $stmt->fetchAll(); $stmt->closeCursor(); @@ -243,7 +243,7 @@ class DBConfigService { 'priority' => $builder->createNamedParameter($priority, IQueryBuilder::PARAM_INT), 'type' => $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT) ]); - $query->execute(); + $query->executeStatement(); return $query->getLastInsertId(); } @@ -256,22 +256,22 @@ class DBConfigService { $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_mounts') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_applicable') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_config') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); $builder = $this->connection->getQueryBuilder(); $query = $builder->delete('external_options') ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -285,7 +285,7 @@ class DBConfigService { ->set('mount_point', $builder->createNamedParameter($newMountPoint)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -299,7 +299,7 @@ class DBConfigService { ->set('auth_backend', $builder->createNamedParameter($newAuthBackend)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))); - $query->execute(); + $query->executeStatement(); } /** @@ -318,14 +318,14 @@ class DBConfigService { ->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)) ->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)) ->setValue('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR)) - ->execute(); + ->executeStatement(); } catch (UniqueConstraintViolationException $e) { $builder = $this->connection->getQueryBuilder(); $query = $builder->update('external_config') ->set('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))) ->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))); - $query->execute(); + $query->executeStatement(); } } @@ -341,14 +341,14 @@ class DBConfigService { ->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)) ->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)) ->setValue('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR)) - ->execute(); + ->executeStatement(); } catch (UniqueConstraintViolationException $e) { $builder = $this->connection->getQueryBuilder(); $query = $builder->update('external_options') ->set('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR)) ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))) ->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))); - $query->execute(); + $query->executeStatement(); } } @@ -359,7 +359,7 @@ class DBConfigService { ->setValue('mount_id', $builder->createNamedParameter($mountId)) ->setValue('type', $builder->createNamedParameter($type)) ->setValue('value', $builder->createNamedParameter($value)) - ->execute(); + ->executeStatement(); } catch (UniqueConstraintViolationException $e) { // applicable exists already } @@ -377,11 +377,11 @@ class DBConfigService { $query = $query->andWhere($builder->expr()->eq('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))); } - $query->execute(); + $query->executeStatement(); } private function getMountsFromQuery(IQueryBuilder $query) { - $result = $query->execute(); + $result = $query->executeQuery(); $mounts = $result->fetchAll(); $uniqueMounts = []; foreach ($mounts as $mount) { @@ -432,7 +432,7 @@ class DBConfigService { ->from($table) ->where($builder->expr()->in('mount_id', $placeHolders)); - $result = $query->execute(); + $result = $query->executeQuery(); $rows = $result->fetchAll(); $result->closeCursor(); diff --git a/apps/files_sharing/lib/Migration/SetAcceptedStatus.php b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php index 43a3c4aad74..22774a9193c 100644 --- a/apps/files_sharing/lib/Migration/SetAcceptedStatus.php +++ b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php @@ -17,16 +17,10 @@ use OCP\Share\IShare; 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, + ) { } /** @@ -48,11 +42,10 @@ class SetAcceptedStatus implements IRepairStep { } $query = $this->connection->getQueryBuilder(); - $query - ->update('share') + $query->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/build/psalm-baseline.xml b/build/psalm-baseline.xml index b6137b7f0c1..2a2c3d8dc94 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -2167,14 +2167,6 @@ <code><![CDATA[$mimetype]]></code> </ParamNameMismatch> </file> - <file src="lib/private/Files/Type/Loader.php"> - <InvalidReturnStatement> - <code><![CDATA[$update->execute()]]></code> - </InvalidReturnStatement> - <InvalidReturnType> - <code><![CDATA[int]]></code> - </InvalidReturnType> - </file> <file src="lib/private/Files/Utils/Scanner.php"> <LessSpecificReturnStatement> <code><![CDATA[$mounts]]></code> diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 41e0c662212..d7326a7a019 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -258,7 +258,6 @@ class Manager implements ICommentsManager { throw new NotFoundException(); } - $comment = $this->getCommentFromData($data); $this->cache($comment); return $comment; @@ -1278,7 +1277,7 @@ class Manager implements ICommentsManager { ->andWhere($qb->expr()->eq('actor_id', $qb->createParameter('id'))) ->setParameter('type', $actorType) ->setParameter('id', $actorId) - ->execute(); + ->executeStatement(); $this->commentsCache = []; @@ -1303,7 +1302,7 @@ class Manager implements ICommentsManager { ->andWhere($qb->expr()->eq('object_id', $qb->createParameter('id'))) ->setParameter('type', $objectType) ->setParameter('id', $objectId) - ->execute(); + ->executeStatement(); $this->commentsCache = []; @@ -1324,7 +1323,7 @@ class Manager implements ICommentsManager { ->setParameter('user_id', $user->getUID()); try { - $affectedRows = $query->execute(); + $affectedRows = $query->executeStatement(); } catch (DriverException $e) { $this->logger->error($e->getMessage(), [ 'exception' => $e, @@ -1369,7 +1368,7 @@ class Manager implements ICommentsManager { ->setParameter('user_id', $user->getUID(), IQueryBuilder::PARAM_STR) ->setParameter('object_type', $objectType, IQueryBuilder::PARAM_STR) ->setParameter('object_id', $objectId, IQueryBuilder::PARAM_STR) - ->execute(); + ->executeStatement(); if ($affectedRows > 0) { return; @@ -1377,7 +1376,7 @@ class Manager implements ICommentsManager { $qb->insert('comments_read_markers') ->values($values) - ->execute(); + ->executeStatement(); } /** @@ -1431,7 +1430,7 @@ class Manager implements ICommentsManager { ->setParameter('object_id', $objectId); try { - $affectedRows = $query->execute(); + $affectedRows = $query->executeStatement(); } catch (DriverException $e) { $this->logger->error($e->getMessage(), [ 'exception' => $e, diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 9a6f7d41faa..adf118ad422 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -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); @@ -320,19 +320,19 @@ class Cache implements ICache { } /** - * update the metadata of an existing file or folder in the cache + * Update the metadata of an existing file or folder in the cache * - * @param int $id the fileid of the existing file or folder - * @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged + * @param int $id The fileid of the existing file or folder + * @param array $data [$key => $value] The metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged */ public function update($id, array $data) { if (isset($data['path'])) { - // normalize path + // Normalize path $data['path'] = $this->normalize($data['path']); } if (isset($data['name'])) { - // normalize path + // Normalize name $data['name'] = $this->normalize($data['name']); } @@ -355,22 +355,21 @@ class Cache implements ICache { $query->set($key, $query->createNamedParameter($value)); } - $query->execute(); + $query->executeStatement(); } if (count($extensionValues)) { - try { - $query = $this->getQueryBuilder(); - $query->insert('filecache_extended'); - $query->hintShardKey('storage', $this->getNumericStorageId()); + // Check if the record already exists + $query = $this->getQueryBuilder(); + $query->select('fileid') + ->from('filecache_extended') + ->whereFileId($id) + ->setMaxResults(1); - $query->setValue('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)); - foreach ($extensionValues as $column => $value) { - $query->setValue($column, $query->createNamedParameter($value)); - } + $result = $query->executeQuery()->fetchOne(); - $query->execute(); - } catch (UniqueConstraintViolationException $e) { + if ($result) { + // Record exists, perform an update $query = $this->getQueryBuilder(); $query->update('filecache_extended') ->whereFileId($id) @@ -386,7 +385,19 @@ class Cache implements ICache { $query->set($key, $query->createNamedParameter($value)); } - $query->execute(); + $query->executeStatement(); + } else { + // Record does not exist, perform an insert + $query = $this->getQueryBuilder(); + $query->insert('filecache_extended'); + $query->hintShardKey('storage', $this->getNumericStorageId()); + + $query->setValue('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)); + foreach ($extensionValues as $column => $value) { + $query->setValue($column, $query->createNamedParameter($value)); + } + + $query->executeStatement(); } } @@ -468,7 +479,7 @@ class Cache implements ICache { ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); - $result = $query->execute(); + $result = $query->executeQuery(); $id = $result->fetchOne(); $result->closeCursor(); @@ -523,13 +534,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 +588,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 +614,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 +776,7 @@ class Cache implements ICache { $query->set('encrypted', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)); } - $query->execute(); + $query->executeStatement(); $this->connection->commit(); @@ -800,12 +811,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 +841,7 @@ class Cache implements ICache { ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); - $result = $query->execute(); + $result = $query->executeQuery(); $size = $result->fetchOne(); $result->closeCursor(); @@ -919,7 +930,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 +976,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 +1050,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 +1081,7 @@ class Cache implements ICache { ->orderBy('fileid', 'DESC') ->setMaxResults(1); - $result = $query->execute(); + $result = $query->executeQuery(); $id = $result->fetchOne(); $result->closeCursor(); @@ -1095,7 +1106,7 @@ class Cache implements ICache { ->whereStorageId($this->getNumericStorageId()) ->whereFileId($id); - $result = $query->execute(); + $result = $query->executeQuery(); $path = $result->fetchOne(); $result->closeCursor(); @@ -1121,7 +1132,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/Storage.php b/lib/private/Files/Cache/Storage.php index 8d99a268dc0..edd259fa18f 100644 --- a/lib/private/Files/Cache/Storage.php +++ b/lib/private/Files/Cache/Storage.php @@ -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/Type/Loader.php b/lib/private/Files/Type/Loader.php index 407df59b2e2..5fbe4139759 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -21,8 +21,6 @@ use OCP\IDBConnection; class Loader implements IMimeTypeLoader { use TTransactional; - private IDBConnection $dbConnection; - /** @psalm-var array<int, string> */ protected array $mimetypes; @@ -32,8 +30,9 @@ class Loader implements IMimeTypeLoader { /** * @param IDBConnection $dbConnection */ - public function __construct(IDBConnection $dbConnection) { - $this->dbConnection = $dbConnection; + public function __construct( + private IDBConnection $dbConnection, + ) { $this->mimetypes = []; $this->mimetypeIds = []; } @@ -161,6 +160,6 @@ class Loader implements IMimeTypeLoader { $update->func()->lower('name'), $update->createNamedParameter('%' . $this->dbConnection->escapeLikeParameter('.' . $ext)) )); - return $update->execute(); + return $update->executeStatement(); } } diff --git a/lib/private/Repair/RepairDavShares.php b/lib/private/Repair/RepairDavShares.php index 36e3c397a39..8199d3dff27 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; } /** @@ -64,7 +52,7 @@ class RepairDavShares implements IRepairStep { ->set('principaluri', $updateQuery->createParameter('updatedPrincipalUri')) ->where($updateQuery->expr()->eq('id', $updateQuery->createParameter('shareId'))); - $statement = $qb->execute(); + $statement = $qb->executeQuery(); while ($share = $statement->fetch()) { $gid = substr($share['principaluri'], strlen(self::GROUP_PRINCIPAL_PREFIX)); $decodedGid = urldecode($gid); @@ -93,7 +81,7 @@ class RepairDavShares implements IRepairStep { $updateQuery ->setParameter('updatedPrincipalUri', $fixedPrincipal) ->setParameter('shareId', $share['id']) - ->execute(); + ->executeStatement(); $this->logger->info('Repaired principal for dav share {id} from {old} to {new}', $logParameters); } catch (Exception $e) { $logParameters['message'] = $e->getMessage(); diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index af993b7f314..07bdbe03275 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) { @@ -946,7 +946,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 +1099,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 +1179,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv return; } - $qb->execute(); + $qb->executeStatement(); } /** @@ -1198,7 +1198,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 +1215,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv foreach ($chunks as $chunk) { $qb->setParameter('parents', $chunk, IQueryBuilder::PARAM_INT_ARRAY); - $qb->execute(); + $qb->executeStatement(); } } @@ -1226,7 +1226,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 +1342,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 +1659,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/User/Database.php b/lib/private/User/Database.php index 2d3808e9dc7..99ff426067b 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -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; } @@ -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; |