]> source.dussan.org Git - nextcloud-server.git/commitdiff
chore(db): redirect write queries to master in clustered setups dbQueriesToMaster
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>
Tue, 15 Oct 2024 09:13:51 +0000 (11:13 +0200)
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>
Tue, 15 Oct 2024 17:42:35 +0000 (19:42 +0200)
fix: psalm baseline

fix: remove is_int

fix: return bool

fix: lint

fix: cache

fix: constraint violation

fix: typo

fix: tests

12 files changed:
apps/dav/lib/CardDAV/CardDavBackend.php
apps/files/lib/Command/RepairTree.php
apps/files_external/lib/Service/DBConfigService.php
apps/files_sharing/lib/Migration/SetAcceptedStatus.php
build/psalm-baseline.xml
lib/private/Comments/Manager.php
lib/private/Files/Cache/Cache.php
lib/private/Files/Cache/Storage.php
lib/private/Files/Type/Loader.php
lib/private/Repair/RepairDavShares.php
lib/private/Share20/DefaultShareProvider.php
lib/private/User/Database.php

index b94da9fa7ed1a2adefb3ab5689b7b55bf0c09bcd..f7d0a888efd79d35292e45a22b816edb2de44881 100644 (file)
@@ -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();
 
index 622ccba48a39d6925e1059b3de0a920f2f4e5195..222ff7db02e7bb9a5a3ae1b427d2c66e46d7953d 100644 (file)
@@ -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 {
index 6fb7e01271e3e3a17178bf05315a27a723309407..0d46f3f379fbeedd8fb972b507fcafc55533d0d8 100644 (file)
@@ -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();
 
index 43a3c4aad740e923eeace17b08d5eba02bd6ebdb..22774a9193c4a3762aea65a6cbd5880c66f58abb 100644 (file)
@@ -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() {
index b6137b7f0c1fb423a47b90cf5c83694dc6118d5d..2a2c3d8dc9436f119014c3edb98df725efd2acab 100644 (file)
       <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>
index 41e0c6622128ff19083b48a135c881070a7429ed..d7326a7a019ef388c9a922c58762599f45e66efc 100644 (file)
@@ -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,
index 9a6f7d41faa22e779197561d90d591deadba3f9a..adf118ad42270d06aa84e9526c7d1034e1979714 100644 (file)
@@ -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();
 
index 8d99a268dc043a8b6013ae5dd7e1d2c2bd7a12a2..edd259fa18f848e47d3d82da620cac92a998721c 100644 (file)
@@ -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();
                }
        }
 
index 407df59b2e2983267301c4cb981b35e89cedf82c..5fbe4139759bee6501a88b8a778313bdfa915240 100644 (file)
@@ -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();
        }
 }
index 36e3c397a392647d9294dbc821a7bee15b52d15f..8199d3dff2784d50c9a32aaca5da7fd5d47a6fce 100644 (file)
@@ -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();
index af993b7f314c80c90503d1420d5e22e1b10efe09..07bdbe03275a385862bc56bee6826576e680a4dc 100644 (file)
@@ -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);
index 2d3808e9dc77366884d5f1ef9f34614e9603ab28..99ff426067be4856e2d5a8807f87f0a14a251e3f 100644 (file)
@@ -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;