From 31b781ed22e742d2b773f474e6ee8e0e9a2fbbc2 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Mon, 3 Mar 2025 22:54:22 +0100 Subject: [PATCH 01/26] IBX-8471: [Composer] Dropped obsolete symfony/proxy-manager-bridge --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 976626e245..470b4ea7e4 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,6 @@ "phpstan/phpstan-symfony": "^2.0", "phpunit/phpunit": "^9.6", "symfony/phpunit-bridge": "^5.4", - "symfony/proxy-manager-bridge": "^6.4", "symfony/runtime": "^6.4.0" }, "conflict": { From a9f329dac296ec71d67346637b794b0789293dd9 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Mon, 3 Mar 2025 22:54:23 +0100 Subject: [PATCH 02/26] IBX-8471: [Composer] Bumped Symfony packages requirements to ^7.2 --- composer.json | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 470b4ea7e4..045aa43078 100644 --- a/composer.json +++ b/composer.json @@ -35,27 +35,27 @@ "pagerfanta/pagerfanta": "^3.6.2", "psr/event-dispatcher": "^1.0", "symfony-cmf/routing": "^3.0", - "symfony/cache": "^6.4.0", - "symfony/console": "^6.4.0", - "symfony/dependency-injection": "^6.4.0", - "symfony/event-dispatcher": "^6.4.0", - "symfony/expression-language": "^6.4.0", - "symfony/framework-bundle": "^6.4.0", - "symfony/http-client": "^6.4.0", - "symfony/http-foundation": "^6.4.0", - "symfony/http-kernel": "^6.4.0", - "symfony/mime": "^6.4.0", + "symfony/cache": "^7.2", + "symfony/console": "^7.2", + "symfony/dependency-injection": "^7.2", + "symfony/event-dispatcher": "^7.2", + "symfony/expression-language": "^7.2", + "symfony/framework-bundle": "^7.2", + "symfony/http-client": "^7.2", + "symfony/http-foundation": "^7.2", + "symfony/http-kernel": "^7.2", + "symfony/mime": "^7.2", "symfony/polyfill-php80": "^1.27", - "symfony/process": "^6.4.0", - "symfony/security-bundle": "^6.4.0", - "symfony/security-core": "^6.4.0", - "symfony/security-http": "^6.4.0", - "symfony/serializer": "^6.4.0", + "symfony/process": "^7.2", + "symfony/security-bundle": "^7.2", + "symfony/security-core": "^7.2", + "symfony/security-http": "^7.2", + "symfony/serializer": "^7.2", "symfony/templating": "^6.4.0", - "symfony/translation": "^6.4.0", - "symfony/validator": "^6.4.0", - "symfony/var-dumper": "^6.4.0", - "symfony/yaml": "^6.4.0", + "symfony/translation": "^7.2", + "symfony/validator": "^7.2", + "symfony/var-dumper": "^7.2", + "symfony/yaml": "^7.2", "twig/extra-bundle": "^3.0", "twig/twig": ">=3.0 <3.16 || ^3.19.0" }, @@ -70,8 +70,8 @@ "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-symfony": "^2.0", "phpunit/phpunit": "^9.6", - "symfony/phpunit-bridge": "^5.4", - "symfony/runtime": "^6.4.0" + "symfony/phpunit-bridge": "^7.2", + "symfony/runtime": "^7.2" }, "conflict": { "doctrine/dbal": "2.7.0", From 94aa76922873f5acb706d125a3357deea445cce5 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Mon, 3 Mar 2025 22:54:24 +0100 Subject: [PATCH 03/26] IBX-8471: [Composer] Bumped 3rd party packages compatible with for Symfony 7 --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 045aa43078..341c5c6673 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,11 @@ "ext-mbstring": "*", "ext-xsl": "*", "composer/package-versions-deprecated": "^1.11", - "doctrine/dbal": "^2.13.0", - "doctrine/doctrine-bundle": "^2.0", + "doctrine/dbal": "^3.7.0", + "doctrine/doctrine-bundle": "^2.11.0", "doctrine/orm": "^2.7", "friendsofphp/proxy-manager-lts": "^1.0", - "friendsofsymfony/http-cache-bundle": "^2.8", + "friendsofsymfony/http-cache-bundle": "^3.0", "friendsofsymfony/jsrouting-bundle": "^3.5", "ibexa/doctrine-schema": "~5.0.x-dev", "jms/translation-bundle": "^2.4", @@ -65,7 +65,7 @@ "ibexa/code-style": "~2.0.0", "ibexa/rector": "~5.0.x-dev", "jenner/simple_fork": "^1.2", - "matthiasnoback/symfony-dependency-injection-test": "^4.1", + "matthiasnoback/symfony-dependency-injection-test": "^5.0", "phpstan/phpstan": "^2.0", "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-symfony": "^2.0", From d53b10005c913c4ce47c52e412206563c7904b7e Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Mon, 3 Mar 2025 22:54:25 +0100 Subject: [PATCH 04/26] [TMP] Switched to dev branch of ibexa packages --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 341c5c6673..368c8457ce 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "friendsofphp/proxy-manager-lts": "^1.0", "friendsofsymfony/http-cache-bundle": "^3.0", "friendsofsymfony/jsrouting-bundle": "^3.5", - "ibexa/doctrine-schema": "~5.0.x-dev", + "ibexa/doctrine-schema": "dev-ibx-8471-symfony-7 as 5.0.x-dev", "jms/translation-bundle": "^2.4", "league/flysystem-memory": "^2.0.6", "liip/imagine-bundle": "^2.3", @@ -63,7 +63,7 @@ "behat/behat": "^3.6.1", "friends-of-behat/mink-extension": "^2.4", "ibexa/code-style": "~2.0.0", - "ibexa/rector": "~5.0.x-dev", + "ibexa/rector": "dev-ibx-8471-symfony-7 as 5.0.x-dev", "jenner/simple_fork": "^1.2", "matthiasnoback/symfony-dependency-injection-test": "^5.0", "phpstan/phpstan": "^2.0", From a7e8a51bfe3ec74492cdce1d19429db94808db56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 09:53:19 +0200 Subject: [PATCH 05/26] Fixed incompatible Ibexa\Bundle\IO\IbexaIOBundle::$extension declaration --- src/bundle/IO/IbexaIOBundle.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/bundle/IO/IbexaIOBundle.php b/src/bundle/IO/IbexaIOBundle.php index 5cb0049493..284daff939 100644 --- a/src/bundle/IO/IbexaIOBundle.php +++ b/src/bundle/IO/IbexaIOBundle.php @@ -16,9 +16,6 @@ class IbexaIOBundle extends Bundle { - /** @var \Ibexa\Bundle\IO\DependencyInjection\IbexaIOExtension|null */ - protected $extension; - public function build(ContainerBuilder $container): void { /** @var \Ibexa\Bundle\IO\DependencyInjection\IbexaIOExtension $extension */ From 0d302e8f33e6170896e4d376e1053779690efea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 09:53:40 +0200 Subject: [PATCH 06/26] Fixed incompatible Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface implementations --- src/bundle/Core/Cache/Warmer/ProxyCacheWarmer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundle/Core/Cache/Warmer/ProxyCacheWarmer.php b/src/bundle/Core/Cache/Warmer/ProxyCacheWarmer.php index 58f4b054ea..9a18e26704 100644 --- a/src/bundle/Core/Cache/Warmer/ProxyCacheWarmer.php +++ b/src/bundle/Core/Cache/Warmer/ProxyCacheWarmer.php @@ -47,7 +47,7 @@ public function isOptional(): bool return false; } - public function warmUp($cacheDir): array + public function warmUp($cacheDir, ?string $buildDir = null): array { $this->proxyGenerator->warmUp(self::PROXY_CLASSES); From 23967313d38e22f534e8230515df33832040c000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 10:18:21 +0200 Subject: [PATCH 07/26] [symfony/console] Fixed incompatible Symfony\Component\Console\Output\Output implementations --- tests/bundle/Core/EventListener/Stubs/TestOutput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bundle/Core/EventListener/Stubs/TestOutput.php b/tests/bundle/Core/EventListener/Stubs/TestOutput.php index 3243bac942..42c4c6ad47 100644 --- a/tests/bundle/Core/EventListener/Stubs/TestOutput.php +++ b/tests/bundle/Core/EventListener/Stubs/TestOutput.php @@ -21,7 +21,7 @@ public function clear() $this->output = ''; } - protected function doWrite($message, $newline) + protected function doWrite($message, $newline): void { $this->output .= $message . ($newline ? "\n" : ''); } From b85209344aacf5159c71fb0d260b293d1fcd6522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 11:35:17 +0200 Subject: [PATCH 08/26] [doctrine/dbal] Fixed usage of deprecated \Doctrine\DBAL\Query\QueryBuilder::execute method --- .../Core/Command/CleanupVersionsCommand.php | 3 +- .../Command/UpdateTimestampsToUTCCommand.php | 6 +- .../VirtualFieldDuplicateFixCommand.php | 8 +- .../LegacyStorageImageFileRowReader.php | 2 +- .../LegacyStorageFileRowReader.php | 2 +- .../Persistence/Fixture/FixtureImporter.php | 2 +- .../Gateway/DoctrineStorage.php | 14 +- .../ImageStorage/Gateway/DoctrineStorage.php | 26 ++-- .../Gateway/DoctrineStorage.php | 16 +-- .../Gateway/DoctrineStorage.php | 8 +- .../UrlStorage/Gateway/DoctrineStorage.php | 16 +-- .../UserStorage/Gateway/DoctrineStorage.php | 22 ++-- .../IO/IOMetadataHandler/LegacyDFSCluster.php | 8 +- .../Bookmark/Gateway/DoctrineDatabase.php | 14 +- .../Converter/RelationListConverter.php | 2 +- .../Content/Gateway/DoctrineDatabase.php | 124 +++++++++--------- .../Language/Gateway/DoctrineDatabase.php | 16 +-- .../Location/Gateway/DoctrineDatabase.php | 94 ++++++------- .../ObjectState/Gateway/DoctrineDatabase.php | 48 +++---- .../Section/Gateway/DoctrineDatabase.php | 20 +-- .../Content/Type/Gateway/DoctrineDatabase.php | 76 +++++------ .../UrlAlias/Gateway/DoctrineDatabase.php | 66 +++++----- .../UrlWildcard/Gateway/DoctrineDatabase.php | 18 +-- .../Content/Doctrine/DoctrineGateway.php | 8 +- .../Location/Doctrine/DoctrineGateway.php | 4 +- .../Notification/Gateway/DoctrineDatabase.php | 14 +- .../Setting/Gateway/DoctrineDatabase.php | 10 +- .../Token/Doctrine/DoctrineGateway.php | 6 +- .../TokenType/Doctrine/DoctrineGateway.php | 4 +- .../Legacy/URL/Gateway/DoctrineDatabase.php | 12 +- .../Legacy/User/Gateway/DoctrineDatabase.php | 22 ++-- .../User/Role/Gateway/DoctrineDatabase.php | 52 ++++---- .../LimitationHandler/ObjectStateHandler.php | 2 +- .../Gateway/DoctrineDatabase.php | 10 +- src/lib/Search/Common/Indexer.php | 5 +- .../Gateway/CriterionHandler/FullText.php | 2 +- .../Content/Gateway/DoctrineDatabase.php | 4 +- .../Search/Legacy/Content/IndexerGateway.php | 12 +- .../Location/Gateway/DoctrineDatabase.php | 4 +- .../WordIndexer/Repository/SearchIndex.php | 18 +-- .../Core/Repository/BaseTrashServiceTest.php | 2 +- .../FieldType/ImageIntegrationTest.php | 4 +- .../Core/Repository/LocationServiceTest.php | 2 +- .../Core/Repository/URLAliasServiceTest.php | 8 +- .../Core/Repository/UserServiceTest.php | 2 +- .../Url/Gateway/DoctrineStorageTest.php | 8 +- .../Content/Gateway/DoctrineDatabaseTest.php | 10 +- .../Location/Gateway/DoctrineDatabaseTest.php | 10 +- .../Gateway/DoctrineDatabaseTrashTest.php | 2 +- .../Content/UrlAlias/UrlAliasHandlerTest.php | 2 +- tests/lib/Persistence/Legacy/TestCase.php | 2 +- .../Gateway/DoctrineDatabaseTest.php | 2 +- 52 files changed, 427 insertions(+), 427 deletions(-) diff --git a/src/bundle/Core/Command/CleanupVersionsCommand.php b/src/bundle/Core/Command/CleanupVersionsCommand.php index fc87383bbf..84dd621215 100644 --- a/src/bundle/Core/Command/CleanupVersionsCommand.php +++ b/src/bundle/Core/Command/CleanupVersionsCommand.php @@ -273,8 +273,7 @@ protected function getObjectsIds($keep, $status, $excludedContentTypes = []) )->setParameter('contentTypes', $excludedContentTypes, Connection::PARAM_STR_ARRAY); } - /** @var \Doctrine\DBAL\ForwardCompatibility\Result $stmt */ - $stmt = $query->execute(); + $stmt = $query->executeQuery(); return $stmt->fetchFirstColumn(); } diff --git a/src/bundle/Core/Command/UpdateTimestampsToUTCCommand.php b/src/bundle/Core/Command/UpdateTimestampsToUTCCommand.php index ecbb9940d7..d4c1cc1d37 100644 --- a/src/bundle/Core/Command/UpdateTimestampsToUTCCommand.php +++ b/src/bundle/Core/Command/UpdateTimestampsToUTCCommand.php @@ -321,7 +321,7 @@ protected function getTimestampBasedFields($offset, $limit) ->setParameter('toTimestamp', $this->to); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(PDO::FETCH_ASSOC); } @@ -359,7 +359,7 @@ protected function countTimestampBasedFields(): int ->setParameter('toTimestamp', $this->to); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int) $statement->fetchColumn(); } @@ -471,7 +471,7 @@ protected function updateTimestampToUTC( ->setParameter('id', $contentAttributeId) ->setParameter('version', $contentAttributeVersion); - $query->execute(); + $query->executeStatement(); } /** diff --git a/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php b/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php index 134c86acec..d617e930c7 100644 --- a/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php +++ b/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php @@ -165,7 +165,7 @@ private function getDuplicatedAttributeTotalCount( ->from('ezcontentobject_attribute', 'a') ->having('instances > 1'); - $count = (int) $query->execute()->rowCount(); + $count = (int) $query->executeQuery()->rowCount(); if ($count > 0) { $style->warning( @@ -200,7 +200,7 @@ private function getDuplicatedAttributesBatch(int $batchSize): array ->setFirstResult(0) ->setMaxResults($batchSize); - return $query->execute()->fetchAllAssociative(); + return $query->executeQuery()->fetchAllAssociative(); } /** @@ -229,7 +229,7 @@ private function getDuplicatedAttributeIds(array $attribute): array ->setFirstResult(1); $query->setParameters($attribute); - $result = $query->execute()->fetchFirstColumn(); + $result = $query->executeQuery()->fetchFirstColumn(); return array_map('intval', $result); } @@ -259,6 +259,6 @@ private function deleteAttributes(array $ids): int ->delete('ezcontentobject_attribute') ->andWhere($query->expr()->in('id', array_map('strval', $ids))); - return (int)$query->execute(); + return (int)$query->executeStatement(); } } diff --git a/src/bundle/Core/Imagine/VariationPurger/LegacyStorageImageFileRowReader.php b/src/bundle/Core/Imagine/VariationPurger/LegacyStorageImageFileRowReader.php index 0681bb2de1..4b593b0599 100644 --- a/src/bundle/Core/Imagine/VariationPurger/LegacyStorageImageFileRowReader.php +++ b/src/bundle/Core/Imagine/VariationPurger/LegacyStorageImageFileRowReader.php @@ -26,7 +26,7 @@ public function init() { $selectQuery = $this->connection->createQueryBuilder(); $selectQuery->select('filepath')->from('ezimagefile'); - $this->statement = $selectQuery->execute(); + $this->statement = $selectQuery->executeQuery(); } public function getRow() diff --git a/src/bundle/IO/Migration/FileLister/FileRowReader/LegacyStorageFileRowReader.php b/src/bundle/IO/Migration/FileLister/FileRowReader/LegacyStorageFileRowReader.php index c68d4bf697..f34a895716 100644 --- a/src/bundle/IO/Migration/FileLister/FileRowReader/LegacyStorageFileRowReader.php +++ b/src/bundle/IO/Migration/FileLister/FileRowReader/LegacyStorageFileRowReader.php @@ -29,7 +29,7 @@ final public function init() $selectQuery ->select('filename', 'mime_type') ->from($this->getStorageTable()); - $this->statement = $selectQuery->execute(); + $this->statement = $selectQuery->executeQuery(); } /** diff --git a/src/contracts/Test/Persistence/Fixture/FixtureImporter.php b/src/contracts/Test/Persistence/Fixture/FixtureImporter.php index 6288cfa250..59532a2fbb 100644 --- a/src/contracts/Test/Persistence/Fixture/FixtureImporter.php +++ b/src/contracts/Test/Persistence/Fixture/FixtureImporter.php @@ -77,7 +77,7 @@ private function truncateTables(array $tables): void ); } catch (DBALException | PDOException $e) { // Fallback to DELETE if TRUNCATE failed (because of FKs for instance) - $this->connection->createQueryBuilder()->delete($table)->execute(); + $this->connection->createQueryBuilder()->delete($table)->executeStatement(); } } } diff --git a/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php index 5fe78a8b06..f5bd5612a9 100644 --- a/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php @@ -176,7 +176,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field) ->setParameter('versionNo', $versionInfo->versionNo, ParameterType::INTEGER) ; - $updateQuery->execute(); + $updateQuery->executeQuery(); } /** @@ -192,7 +192,7 @@ protected function storeNewFieldData(VersionInfo $versionInfo, Field $field) $this->setInsertColumns($insertQuery, $versionInfo, $field); - $insertQuery->execute(); + $insertQuery->executeStatement(); } /** @@ -241,7 +241,7 @@ public function getFileReferenceData($fieldId, $versionNo) ->setParameter('versionNo', $versionNo, PDO::PARAM_INT) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); @@ -337,7 +337,7 @@ public function removeFileReferences(array $fieldIds, $versionNo) ->setParameter('versionNo', $versionNo, PDO::PARAM_INT) ; - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } /** @@ -367,7 +367,7 @@ public function removeFileReference($fieldId, $versionNo) ->setParameter('versionNo', $versionNo, PDO::PARAM_INT) ; - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } /** @@ -406,7 +406,7 @@ public function getReferencedFiles(array $fieldIds, $versionNo) ->setParameter('versionNo', $versionNo, PDO::PARAM_INT) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); return array_map( function ($row) { @@ -460,7 +460,7 @@ public function countFileReferences(array $files) ) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); $countMap = []; foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) { diff --git a/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php index f261b8d2c7..116cd1a63e 100644 --- a/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php @@ -79,7 +79,7 @@ public function getNodePathString(VersionInfo $versionInfo) ->setParameter('versionNo', $versionInfo->versionNo, PDO::PARAM_INT) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); return $statement->fetchOne(); } @@ -108,7 +108,7 @@ public function storeImageReference($uri, $fieldId) ->setParameter('path', $path) ; - $insertQuery->execute(); + $insertQuery->executeStatement(); } /** @@ -143,7 +143,7 @@ public function getXmlForImages($versionNo, array $fieldIds) ->setParameter('fieldIds', $fieldIds, Connection::PARAM_INT_ARRAY) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); $fieldLookup = []; foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) { @@ -172,7 +172,7 @@ public function getAllVersionsImageXmlForFieldId(int $fieldId): array ->setParameter('field_id', $fieldId, PDO::PARAM_INT) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); $fieldLookup = []; foreach ($statement->fetchAllAssociative() as $row) { @@ -221,7 +221,7 @@ public function removeImageReferences($uri, $versionNo, $fieldId): void ->setParameter('likePath', $path . '%') ; - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } /** @@ -248,7 +248,7 @@ public function countImageReferences($uri): int ->setParameter('filepath', $path) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); return (int) $statement->fetchOne(); } @@ -270,7 +270,7 @@ public function isImageReferenced(string $uri): bool ->setParameter('likePath', $path) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); return (bool)$statement->fetchOne(); } @@ -283,7 +283,7 @@ public function countDistinctImagesData(): int ->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); return (int) $statement->fetchOne(); } @@ -327,7 +327,7 @@ protected function canRemoveImageReference($path, $versionNo, $fieldId): bool ->setParameter('versionNo', $versionNo, PDO::PARAM_INT) ; - $imageXMLs = $selectQuery->execute()->fetchAll(FetchMode::COLUMN); + $imageXMLs = $selectQuery->executeQuery()->fetchAll(FetchMode::COLUMN); foreach ($imageXMLs as $imageXML) { $storedFilePath = $this->extractFilesFromXml($imageXML)['original'] ?? null; if ($storedFilePath === $path) { @@ -393,7 +393,7 @@ public function getImagesData(int $offset, int $limit): array ->setFirstResult($offset) ->setMaxResults($limit); - return $selectQuery->execute()->fetchAllAssociative(); + return $selectQuery->executeQuery()->fetchAllAssociative(); } public function updateImageData(int $fieldId, int $versionNo, string $xml): void @@ -423,7 +423,7 @@ public function updateImageData(int $fieldId, int $versionNo, string $xml): void ->setParameter('field_id', $fieldId, ParameterType::INTEGER) ->setParameter('version_no', $versionNo, ParameterType::INTEGER) ->setParameter('xml', $xml, ParameterType::STRING) - ->execute() + ->executeStatement() ; } @@ -454,7 +454,7 @@ public function updateImagePath(int $fieldId, string $oldPath, string $newPath): ->setParameter('field_id', $fieldId, ParameterType::INTEGER) ->setParameter('old_path', $oldPath, ParameterType::STRING) ->setParameter('new_path', $newPath, ParameterType::STRING) - ->execute() + ->executeStatement() ; } @@ -487,7 +487,7 @@ public function hasImageReference(string $uri, int $fieldId): bool ->setParameter('field_id', $fieldId) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); return (bool)$statement->fetchOne(); } diff --git a/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php index 0933088521..0855bf59e8 100644 --- a/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php @@ -131,7 +131,7 @@ protected function getAssignedKeywords(int $fieldId, int $versionNo): array ->setParameter('field_id', $fieldId, ParameterType::INTEGER) ->setParameter('version_no', $versionNo, ParameterType::INTEGER); - return $query->execute()->fetchFirstColumn(); + return $query->executeQuery()->fetchFirstColumn(); } /** @@ -152,7 +152,7 @@ protected function loadContentTypeId($fieldDefinitionId): int ) ->setParameter('fieldDefinitionId', $fieldDefinitionId); - $statement = $query->execute(); + $statement = $query->executeQuery(); $row = $statement->fetch(\PDO::FETCH_ASSOC); @@ -209,7 +209,7 @@ protected function getExistingKeywords($keywordList, $contentTypeId) ->setParameter('keywordList', $keywordList, Connection::PARAM_STR_ARRAY) ->setParameter('contentTypeId', $contentTypeId); - $statement = $query->execute(); + $statement = $query->executeQuery(); $existingKeywordMap = []; foreach ($statement->fetchAll(\PDO::FETCH_ASSOC) as $row) { @@ -258,7 +258,7 @@ protected function insertKeywords(array $keywordsToInsert, $contentTypeId) foreach (array_keys($keywordsToInsert) as $keyword) { $insertQuery->setParameter('keyword', $keyword); - $insertQuery->execute(); + $insertQuery->executeStatement(); $keywordIdMap[$keyword] = (int)$this->connection->lastInsertId( $this->getSequenceName(self::KEYWORD_TABLE, 'id') ); @@ -288,7 +288,7 @@ protected function deleteOldKeywordAssignments(int $fieldId, int $versionNo): vo ->setParameter('fieldId', $fieldId, ParameterType::INTEGER) ->setParameter('versionNo', $versionNo, ParameterType::INTEGER); - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } /** @@ -321,7 +321,7 @@ protected function assignKeywords(int $fieldId, array $keywordMap, int $versionN ->setParameter('keywordId', $keywordId, ParameterType::INTEGER) ->setParameter('fieldId', $fieldId, ParameterType::INTEGER) ->setParameter('versionNo', $versionNo, ParameterType::INTEGER); - $insertQuery->execute(); + $insertQuery->executeStatement(); } } @@ -348,7 +348,7 @@ protected function deleteOrphanedKeywords() ) ->where($query->expr()->isNull('attr.id')); - $statement = $query->execute(); + $statement = $query->executeQuery(); $ids = $statement->fetchAll(\PDO::FETCH_COLUMN); if (empty($ids)) { @@ -363,6 +363,6 @@ protected function deleteOrphanedKeywords() ) ->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY); - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } } diff --git a/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php index b09ff51900..49912d1956 100644 --- a/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php @@ -95,7 +95,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field) ->setParameter('versionNo', $versionInfo->versionNo, PDO::PARAM_INT) ; - $updateQuery->execute(); + $updateQuery->executeStatement(); } /** @@ -123,7 +123,7 @@ protected function storeNewFieldData(VersionInfo $versionInfo, Field $field) ->setParameter('versionNo', $versionInfo->versionNo) ; - $insertQuery->execute(); + $insertQuery->executeStatement(); } /** @@ -175,7 +175,7 @@ protected function loadFieldData($fieldId, $versionNo) ->setParameter('versionNo', $versionNo, PDO::PARAM_INT) ; - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); $rows = $statement->fetchAll(PDO::FETCH_ASSOC); if (!isset($rows[0])) { @@ -234,6 +234,6 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds) ->setParameter('versionNo', $versionInfo->versionNo, PDO::PARAM_INT) ; - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } } diff --git a/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php index e989559651..9a8581d875 100644 --- a/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php @@ -50,7 +50,7 @@ public function getIdUrlMap(array $ids) ->where('id IN (:ids)') ->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY); - $statement = $query->execute(); + $statement = $query->executeQuery(); foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) { $map[$row['id']] = $row['url']; } @@ -85,7 +85,7 @@ public function getUrlIdMap(array $urls) ) ->setParameter('urls', $urls, Connection::PARAM_STR_ARRAY); - $statement = $query->execute(); + $statement = $query->executeQuery(); foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) { $map[$row['url']] = $row['id']; } @@ -123,7 +123,7 @@ public function insertUrl($url): int ->setParameter('url', $url) ; - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId( $this->getSequenceName(self::URL_TABLE, 'id') @@ -155,7 +155,7 @@ public function linkUrl($urlId, $fieldId, $versionNo) ->setParameter('url_id', $urlId, PDO::PARAM_INT) ; - $query->execute(); + $query->executeStatement(); } /** @@ -186,7 +186,7 @@ public function unlinkUrl($fieldId, $versionNo, array $excludeUrlIds = []): void ->setParameter('contentobject_attribute_id', $fieldId, ParameterType::INTEGER) ->setParameter('contentobject_attribute_version', $versionNo, ParameterType::INTEGER); - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); $potentiallyOrphanedUrls = $statement->fetchFirstColumn(); if (empty($potentiallyOrphanedUrls)) { @@ -222,7 +222,7 @@ public function unlinkUrl($fieldId, $versionNo, array $excludeUrlIds = []): void ->setParameter('url_ids', $excludeUrlIds, Connection::PARAM_INT_ARRAY); } - $deleteQuery->execute(); + $deleteQuery->executeStatement(); $this->deleteOrphanedUrls($potentiallyOrphanedUrls); } @@ -258,7 +258,7 @@ private function deleteOrphanedUrls(array $potentiallyOrphanedUrls): void ->setParameter('url_ids', $potentiallyOrphanedUrls, Connection::PARAM_INT_ARRAY) ; - $statement = $query->execute(); + $statement = $query->executeQuery(); $ids = $statement->fetchAll(PDO::FETCH_COLUMN); if (empty($ids)) { @@ -272,6 +272,6 @@ private function deleteOrphanedUrls(array $potentiallyOrphanedUrls): void ->setParameter('ids', $ids, Connection::PARAM_STR_ARRAY) ; - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } } diff --git a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php index 8a399fdb06..bc896bb27d 100644 --- a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php @@ -172,7 +172,7 @@ protected function fetchUserId($fieldId): int ->setParameter('fieldId', $fieldId, PDO::PARAM_INT) ; - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int) $statement->fetchOne(); } @@ -206,7 +206,7 @@ protected function fetchUserData($userId) ->setParameter('userId', $userId, PDO::PARAM_INT) ; - $statement = $query->execute(); + $statement = $query->executeQuery(); $rows = $statement->fetchAll(PDO::FETCH_ASSOC); @@ -238,7 +238,7 @@ protected function fetchUserSettings($userId) ->setParameter('userId', $userId, PDO::PARAM_INT) ; - $statement = $query->execute(); + $statement = $query->executeQuery(); $rows = $statement->fetchAll(PDO::FETCH_ASSOC); @@ -293,7 +293,7 @@ protected function insertFieldData(VersionInfo $versionInfo, Field $field): void ->setParameter('passwordUpdatedAt', $field->value->externalData['passwordUpdatedAt']) ; - $insertQuery->execute(); + $insertQuery->executeStatement(); $settingsQuery = $this->connection->createQueryBuilder(); @@ -306,7 +306,7 @@ protected function insertFieldData(VersionInfo $versionInfo, Field $field): void ->setParameter('isEnabled', $field->value->externalData['enabled'], ParameterType::INTEGER) ->setParameter('maxLogin', $field->value->externalData['maxLogin'], ParameterType::INTEGER); - $settingsQuery->execute(); + $settingsQuery->executeStatement(); } protected function updateFieldData(VersionInfo $versionInfo, Field $field): void @@ -334,7 +334,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field): void ->setParameter(':userId', $versionInfo->contentInfo->id, ParameterType::INTEGER) ; - $queryBuilder->execute(); + $queryBuilder->executeStatement(); $settingsQuery = $this->connection->createQueryBuilder(); @@ -352,7 +352,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field): void ) ->setParameter(':userId', $versionInfo->contentInfo->id, ParameterType::INTEGER); - $settingsQuery->execute(); + $settingsQuery->executeStatement(); } public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): bool @@ -374,7 +374,7 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): bool ) ->setParameter('userId', $versionInfo->contentInfo->id, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); $query = $this->connection->createQueryBuilder(); $query @@ -387,7 +387,7 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): bool ) ->setParameter('userId', $versionInfo->contentInfo->id, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); return true; } @@ -417,7 +417,7 @@ protected function isLastRelationToFieldType(array $fieldIds): bool ->groupBy('id') ->having($countExpr . ' > 1'); - $numRows = (int)$checkQuery->execute()->fetchOne(); + $numRows = (int)$checkQuery->executeQuery()->fetchOne(); return $numRows === 0; } @@ -437,7 +437,7 @@ public function countUsersWithUnsupportedHashType(array $supportedHashTypes): in ->setParameter('supportedPasswordHashes', $supportedHashTypes, Connection::PARAM_INT_ARRAY); return $selectQuery - ->execute() + ->executeQuery() ->fetchOne(); } } diff --git a/src/lib/IO/IOMetadataHandler/LegacyDFSCluster.php b/src/lib/IO/IOMetadataHandler/LegacyDFSCluster.php index 241ec7191b..10e876392b 100644 --- a/src/lib/IO/IOMetadataHandler/LegacyDFSCluster.php +++ b/src/lib/IO/IOMetadataHandler/LegacyDFSCluster.php @@ -139,7 +139,7 @@ public function load($spiBinaryFileId) ->andWhere('e.expired != true') ->andWhere('e.mtime > 0') ->setParameter('name_hash', md5($path)) - ->execute() + ->executeQuery() ; if ($result->rowCount() === 0) { @@ -183,7 +183,7 @@ public function exists($spiBinaryFileId): bool ->andWhere('e.expired != true') ->andWhere('e.mtime > 0') ->setParameter('name_hash', md5($path)) - ->execute() + ->executeQuery() ; return $result->rowCount() === 1; @@ -260,7 +260,7 @@ public function getMimeType($spiBinaryFileId) ->andWhere('e.expired != true') ->andWhere('e.mtime > 0') ->setParameter('name_hash', md5($this->addPrefix($spiBinaryFileId))) - ->execute() + ->executeQuery() ; if ($result->rowCount() == 0) { @@ -288,7 +288,7 @@ public function deleteDirectory($spiPath) 'spiPath', addcslashes($this->addPrefix(rtrim($spiPath, '/')), '%_') . '/%' ); - $query->execute(); + $query->executeStatement(); } /** diff --git a/src/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabase.php index 1e195e0e1b..3f5b26630d 100644 --- a/src/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabase.php @@ -47,7 +47,7 @@ public function insertBookmark(Bookmark $bookmark): int ->setParameter('user_id', $bookmark->userId, PDO::PARAM_INT) ->setParameter('location_id', $bookmark->locationId, PDO::PARAM_INT); - $query->execute(); + $query->executeStatement(); return (int) $this->connection->lastInsertId(); } @@ -63,7 +63,7 @@ public function deleteBookmark(int $id): void ->where($query->expr()->eq(self::COLUMN_ID, ':id')) ->setParameter('id', $id, PDO::PARAM_INT); - $query->execute(); + $query->executeStatement(); } /** @@ -78,7 +78,7 @@ public function loadBookmarkDataById(int $id): array ->where($query->expr()->eq(self::COLUMN_ID, ':id')) ->setParameter('id', $id, PDO::PARAM_INT); - return $query->execute()->fetchAll(PDO::FETCH_ASSOC); + return $query->executeQuery()->fetchAll(PDO::FETCH_ASSOC); } /** @@ -97,7 +97,7 @@ public function loadBookmarkDataByUserIdAndLocationId(int $userId, array $locati ->setParameter('user_id', $userId, PDO::PARAM_INT) ->setParameter('location_id', $locationIds, Connection::PARAM_INT_ARRAY); - return $query->execute()->fetchAll(PDO::FETCH_ASSOC); + return $query->executeQuery()->fetchAll(PDO::FETCH_ASSOC); } public function loadUserIdsByLocation(Location $location): array @@ -118,7 +118,7 @@ public function loadUserIdsByLocation(Location $location): array ) ); - return $queryBuilder->execute()->fetchFirstColumn(); + return $queryBuilder->executeQuery()->fetchFirstColumn(); } /** @@ -140,7 +140,7 @@ public function loadUserBookmarks(int $userId, int $offset = 0, int $limit = -1) $query->orderBy(self::COLUMN_ID, 'DESC'); $query->setParameter('user_id', $userId, PDO::PARAM_INT); - return $query->execute()->fetchAll(PDO::FETCH_ASSOC); + return $query->executeQuery()->fetchAll(PDO::FETCH_ASSOC); } /** @@ -155,7 +155,7 @@ public function countUserBookmarks(int $userId): int ->where($query->expr()->eq(self::COLUMN_USER_ID, ':user_id')) ->setParameter('user_id', $userId, PDO::PARAM_INT); - return (int) $query->execute()->fetchOne(); + return (int) $query->executeQuery()->fetchOne(); } /** diff --git a/src/lib/Persistence/Legacy/Content/FieldValue/Converter/RelationListConverter.php b/src/lib/Persistence/Legacy/Content/FieldValue/Converter/RelationListConverter.php index a87709a266..d67e09e740 100644 --- a/src/lib/Persistence/Legacy/Content/FieldValue/Converter/RelationListConverter.php +++ b/src/lib/Persistence/Legacy/Content/FieldValue/Converter/RelationListConverter.php @@ -326,7 +326,7 @@ protected function getRelationXmlHashFromDB(array $destinationContentIds) ) ->setParameter('content_ids', $destinationContentIds, Connection::PARAM_INT_ARRAY); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); return $this->groupResultSetById($stmt->fetchAll(FetchMode::ASSOCIATIVE)); } diff --git a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index 64a080b920..adbc975925 100644 --- a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -154,7 +154,7 @@ public function insertContentObject(CreateStruct $struct, int $currentVersionNo ] ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(self::CONTENT_ITEM_SEQ); } @@ -207,7 +207,7 @@ public function insertVersion(VersionInfo $versionInfo, array $fields): int ] ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(self::CONTENT_VERSION_SEQ); } @@ -280,7 +280,7 @@ public function updateContent( ); if (!empty($query->getQueryPart('set'))) { - $query->execute(); + $query->executeStatement(); } // Handle alwaysAvailable flag update separately as it's a more complex task and has impact on several tables @@ -331,7 +331,7 @@ public function updateVersion(int $contentId, int $versionNo, UpdateStruct $stru ->setParameter('content_id', $contentId, ParameterType::INTEGER) ->setParameter('version_no', $versionNo, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } public function updateAlwaysAvailableFlag(int $contentId, ?bool $alwaysAvailable = null): void @@ -377,7 +377,7 @@ private function updateContentItemAlwaysAvailableFlag( $query->createNamedParameter($contentId, ParameterType::INTEGER, ':contentId') ) ); - $query->execute(); + $query->executeStatement(); } private function updateContentNameAlwaysAvailableFlag( @@ -403,7 +403,7 @@ private function updateContentNameAlwaysAvailableFlag( $query->createNamedParameter($versionNo, ParameterType::INTEGER, ':versionNo') ) ); - $query->execute(); + $query->executeStatement(); } private function updateContentFieldsAlwaysAvailableFlag( @@ -434,7 +434,7 @@ private function updateContentFieldsAlwaysAvailableFlag( if (!$this->languageMaskGenerator->isLanguageMaskComposite($languageMask)) { $this->setLanguageMaskForUpdateQuery($alwaysAvailable, $query, 'language_id'); - $query->execute(); + $query->executeStatement(); return; } @@ -451,7 +451,7 @@ private function updateContentFieldsAlwaysAvailableFlag( ) ->setParameter('languageMaskOperand', self::REMOVE_ALWAYS_AVAILABLE_LANG_MASK_OPERAND) ; - $query->execute(); + $query->executeStatement(); $query->resetQueryPart('set'); // 2. If Content is always available set the flag only on fields in main language @@ -478,7 +478,7 @@ private function updateContentFieldsAlwaysAvailableFlag( $query->createNamedParameter(0, ParameterType::INTEGER, ':zero') ) ); - $query->execute(); + $query->executeStatement(); } } @@ -486,7 +486,7 @@ public function setStatus(int $contentId, int $version, int $status): bool { if ($status !== APIVersionInfo::STATUS_PUBLISHED) { $query = $this->queryBuilder->getSetVersionStatusQuery($contentId, $version, $status); - $rowCount = $query->execute(); + $rowCount = $query->executeStatement(); return $rowCount > 0; } else { @@ -516,7 +516,7 @@ public function setPublishedStatus(int $contentId, int $versionNo): void SQL; $query->andWhere($notExistPublishedVersion); - if (0 === $query->execute()) { + if (0 === $query->executeStatement()) { throw new BadStateException( '$contentId', "Someone just published another version of Content item {$contentId}" @@ -536,7 +536,7 @@ private function markContentAsPublished(int $contentId, int $versionNo): void ->setParameter('status', ContentInfo::STATUS_PUBLISHED, ParameterType::INTEGER) ->setParameter('versionNo', $versionNo, ParameterType::INTEGER) ->setParameter('contentId', $contentId, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -563,7 +563,7 @@ public function insertNewField(Content $content, Field $field, StorageFieldValue ->setParameter('field_id', $nextId, ParameterType::INTEGER); } - $query->execute(); + $query->executeStatement(); return (int)$this->sharedGateway->getLastInsertedId(self::CONTENT_FIELD_SEQ); } @@ -581,7 +581,7 @@ public function insertExistingField( ->setValue('id', ':field_id') ->setParameter('field_id', $field->id, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -663,7 +663,7 @@ public function updateField(Field $field, StorageFieldValue $value): void ->setParameter('field_id', $field->id, ParameterType::INTEGER) ->setParameter('version_no', $field->versionNo, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -708,7 +708,7 @@ public function updateNonTranslatableField( ->setParameter('content_id', $contentId, ParameterType::INTEGER) ->setParameter('version_no', $field->versionNo, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } public function load(int $contentId, ?int $version = null, ?array $translations = null): array @@ -816,7 +816,7 @@ private function internalLoadContent( ); } - return $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function loadContentInfo(int $contentId): array @@ -826,7 +826,7 @@ public function loadContentInfo(int $contentId): array ->where('c.id = :id') ->setParameter('id', $contentId, ParameterType::INTEGER); - $results = $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + $results = $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); if (empty($results)) { throw new NotFound('content', "id: $contentId"); } @@ -841,7 +841,7 @@ public function loadContentInfoList(array $contentIds): array ->where('c.id IN (:ids)') ->setParameter('ids', $contentIds, Connection::PARAM_INT_ARRAY); - return $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function loadContentInfoByRemoteId(string $remoteId): array @@ -851,7 +851,7 @@ public function loadContentInfoByRemoteId(string $remoteId): array ->where('c.remote_id = :id') ->setParameter('id', $remoteId, ParameterType::STRING); - $results = $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + $results = $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); if (empty($results)) { throw new NotFound('content', "remote_id: $remoteId"); } @@ -866,7 +866,7 @@ public function loadContentInfoByLocationId(int $locationId): array ->where('t.node_id = :id') ->setParameter('id', $locationId, ParameterType::INTEGER); - $results = $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + $results = $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); if (empty($results)) { throw new NotFound('content', "node_id: $locationId"); } @@ -907,7 +907,7 @@ public function loadVersionInfo(int $contentId, ?int $versionNo = null): array $queryBuilder->andWhere($expr->eq('v.version', 'c.current_version')); } - return $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -952,7 +952,7 @@ public function loadVersionNoArchivedWithin(int $contentId, int $seconds): array ) )->orderBy('v.modified', 'DESC'); - return $queryBuilder->execute()->fetchAllAssociative(); + return $queryBuilder->executeQuery()->fetchAllAssociative(); } public function countVersionsForUser(int $userId, int $status = VersionInfo::STATUS_DRAFT): int @@ -980,7 +980,7 @@ public function countVersionsForUser(int $userId, int $status = VersionInfo::STA ->setParameter('status', $status, ParameterType::INTEGER) ->setParameter('user_id', $userId, ParameterType::INTEGER); - return (int) $query->execute()->fetchOne(); + return (int) $query->executeQuery()->fetchOne(); } /** @@ -998,7 +998,7 @@ public function listVersionsForUser(int $userId, int $status = VersionInfo::STAT ->setParameter('user_id', $userId, ParameterType::INTEGER) ->orderBy('v.id'); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function loadVersionsForUser( @@ -1027,7 +1027,7 @@ public function loadVersionsForUser( $query->orderBy('v.modified', 'DESC'); $query->addOrderBy('v.id', 'DESC'); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function listVersions(int $contentId, ?int $status = null, int $limit = -1): array @@ -1049,7 +1049,7 @@ public function listVersions(int $contentId, ?int $status = null, int $limit = - $query->orderBy('v.id'); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -1065,7 +1065,7 @@ public function listVersionNumbers(int $contentId): array ->groupBy('version') ->setParameter('contentId', $contentId, ParameterType::INTEGER); - return array_map('intval', $query->execute()->fetchAll(FetchMode::COLUMN)); + return array_map('intval', $query->executeQuery()->fetchAll(FetchMode::COLUMN)); } public function getLastVersionNumber(int $contentId): int @@ -1077,7 +1077,7 @@ public function getLastVersionNumber(int $contentId): int ->where('contentobject_id = :content_id') ->setParameter('content_id', $contentId, ParameterType::INTEGER); - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchOne(); } @@ -1094,7 +1094,7 @@ public function getAllLocationIds(int $contentId): array ->where('contentobject_id = :content_id') ->setParameter('content_id', $contentId, ParameterType::INTEGER); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::COLUMN); } @@ -1126,7 +1126,7 @@ public function getFieldIdsByType( ->setParameter('language_code', $languageCode, ParameterType::STRING); } - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = []; foreach ($statement->fetchAll(FetchMode::ASSOCIATIVE) as $row) { @@ -1155,7 +1155,7 @@ public function deleteRelations(int $contentId, ?int $versionNo = null): void $query->orWhere('to_contentobject_id = :content_id'); } - $query->execute(); + $query->executeStatement(); } public function removeReverseFieldRelations(int $contentId): void @@ -1188,7 +1188,7 @@ public function removeReverseFieldRelations(int $contentId): void ->setParameter('content_id', $contentId, ParameterType::INTEGER) ->setParameter('relation_type', RelationType::FIELD->value | RelationType::ASSET->value, ParameterType::INTEGER); - $statement = $query->execute(); + $statement = $query->executeQuery(); while ($row = $statement->fetch(FetchMode::ASSOCIATIVE)) { if ($row['data_type_string'] === 'ezobjectrelation') { @@ -1212,7 +1212,7 @@ public function removeRelationsByFieldDefinitionId(int $fieldDefinitionId): void ->where('contentclassattribute_id = :field_definition_id') ->setParameter('field_definition_id', $fieldDefinitionId, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -1244,7 +1244,7 @@ private function removeRelationFromRelationListField(int $contentId, array $row) ->setParameter('attribute_id', (int)$row['id'], ParameterType::INTEGER) ->setParameter('version_no', (int)$row['version'], ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -1267,7 +1267,7 @@ private function removeRelationFromRelationField(array $row): void ->setParameter('attribute_id', (int)$row['id'], ParameterType::INTEGER) ->setParameter('version_no', (int)$row['version'], ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -1294,7 +1294,7 @@ private function removeRelationFromAssetField(array $row): void ->setParameter('attribute_id', (int)$row['id'], ParameterType::INTEGER) ->setParameter('version_no', (int)$row['version'], ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } public function deleteField(int $fieldId): void @@ -1306,7 +1306,7 @@ public function deleteField(int $fieldId): void ->setParameter('field_id', $fieldId, ParameterType::INTEGER) ; - $query->execute(); + $query->executeStatement(); } public function deleteFields(int $contentId, ?int $versionNo = null): void @@ -1323,7 +1323,7 @@ public function deleteFields(int $contentId, ?int $versionNo = null): void ->setParameter('version_no', $versionNo, ParameterType::INTEGER); } - $query->execute(); + $query->executeStatement(); } public function deleteVersions(int $contentId, ?int $versionNo = null): void @@ -1340,7 +1340,7 @@ public function deleteVersions(int $contentId, ?int $versionNo = null): void ->setParameter('version_no', $versionNo, ParameterType::INTEGER); } - $query->execute(); + $query->executeStatement(); } public function deleteNames(int $contentId, int $versionNo = null): void @@ -1357,7 +1357,7 @@ public function deleteNames(int $contentId, int $versionNo = null): void ->setParameter('version_no', $versionNo, ParameterType::INTEGER); } - $query->execute(); + $query->executeStatement(); } /** @@ -1376,7 +1376,7 @@ private function contentNameExists(int $contentId, int $version, string $languag ->setParameter('version_no', $version, ParameterType::INTEGER) ->setParameter('language_code', $languageCode, ParameterType::STRING); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); return (int)$stmt->fetch(FetchMode::COLUMN) > 0; } @@ -1420,7 +1420,7 @@ public function setName(int $contentId, int $version, string $name, string $lang ->andWhere('content_translation = :language_code'); } - $query->execute(); + $query->executeStatement(); } /** @@ -1445,7 +1445,7 @@ public function deleteContent(int $contentId): void ->setParameter('content_id', $contentId, ParameterType::INTEGER) ; - $query->execute(); + $query->executeStatement(); } public function loadRelations( @@ -1456,7 +1456,7 @@ public function loadRelations( $query = $this->queryBuilder->createRelationFindQueryBuilder(); $query = $this->prepareRelationQuery($query, $contentId, $contentVersionNo, $relationType); - return $query->execute()->fetchAllAssociative(); + return $query->executeQuery()->fetchAllAssociative(); } public function countRelations( @@ -1470,7 +1470,7 @@ public function countRelations( $query = $this->prepareRelationQuery($query, $contentId, $contentVersionNo, $relationType); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function listRelations( @@ -1488,7 +1488,7 @@ public function listRelations( $query->orderBy('l.id', 'DESC'); - return $query->execute()->fetchAllAssociative(); + return $query->executeQuery()->fetchAllAssociative(); } private function prepareRelationQuery( @@ -1592,7 +1592,7 @@ public function countReverseRelations(int $toContentId, ?int $relationType = nul ); } - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function loadReverseRelations(int $toContentId, ?int $relationType = null): array @@ -1632,7 +1632,7 @@ public function loadReverseRelations(int $toContentId, ?int $relationType = null ->setParameter('relation_type', $relationType, ParameterType::INTEGER); } - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function listReverseRelations( @@ -1677,7 +1677,7 @@ public function listReverseRelations( } $query->orderBy('l.id', 'DESC'); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function insertRelation(RelationCreateStruct $createStruct): int @@ -1716,7 +1716,7 @@ public function insertRelation(RelationCreateStruct $createStruct): int ParameterType::INTEGER ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(self::CONTENT_RELATION_SEQ); } @@ -1737,7 +1737,7 @@ public function loadRelation(int $relationId): array ) ->setParameter('relationId', $relationId, ParameterType::INTEGER); - $result = $query->execute()->fetchAllAssociative(); + $result = $query->executeQuery()->fetchAllAssociative(); $resultCount = count($result); if ($resultCount === 0) { throw new NotFoundException('Relation', $relationId); @@ -1762,7 +1762,7 @@ public function deleteRelation(int $relationId, int $type): void ->setParameter('relation_id', $relationId, ParameterType::INTEGER) ; - $loadedRelationType = $query->execute()->fetchOne(); + $loadedRelationType = $query->executeQuery()->fetchOne(); if (!$loadedRelationType) { return; @@ -1777,7 +1777,7 @@ public function deleteRelation(int $relationId, int $type): void ->setParameter('relation_id', $relationId, ParameterType::INTEGER) ; - $query->execute(); + $query->executeStatement(); } elseif ($loadedRelationType & $type) { // If relation type is composite update bitmask @@ -1797,7 +1797,7 @@ public function deleteRelation(int $relationId, int $type): void ->setParameter('relation_id', $relationId, ParameterType::INTEGER) ; - $query->execute(); + $query->executeStatement(); } } @@ -1813,7 +1813,7 @@ public function getContentIdsByContentTypeId(int $contentTypeId): array ->where('contentclass_id = :content_type_id') ->setParameter('content_type_id', $contentTypeId, ParameterType::INTEGER); - $statement = $query->execute(); + $statement = $query->executeQuery(); return array_map('intval', $statement->fetchAll(FetchMode::COLUMN)); } @@ -1838,7 +1838,7 @@ public function loadVersionedNameData(array $rows): array $query->where($expr->or(...$conditions)); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -1936,7 +1936,7 @@ public function deleteTranslatedFields( ; } - $query->execute(); + $query->executeStatement(); } /** @@ -1993,7 +1993,7 @@ private function deleteTranslationFromContentNames( ; } - $query->execute(); + $query->executeStatement(); } /** @@ -2023,7 +2023,7 @@ private function deleteTranslationFromContentObject($contentId, $languageId) ->setParameter('contentId', $contentId) ; - $rowCount = $query->execute(); + $rowCount = $query->executeQuery(); // no rows updated means that most likely somehow it was the last remaining translation if ($rowCount === 0) { @@ -2079,7 +2079,7 @@ private function deleteTranslationFromContentVersions( ; } - $rowCount = $query->execute(); + $rowCount = $query->executeStatement(); // no rows updated means that most likely somehow it was the last remaining translation if ($rowCount === 0) { @@ -2142,6 +2142,6 @@ public function loadVersionInfoList(array $contentIds): array $expr->eq('v.version', 'c.current_version') ); - return $queryBuilder->execute()->fetchAllAssociative(); + return $queryBuilder->executeQuery()->fetchAllAssociative(); } } diff --git a/src/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabase.php index 5966c59811..62af897a89 100644 --- a/src/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabase.php @@ -52,7 +52,7 @@ public function insertLanguage(Language $language): int ) ->from(self::CONTENT_LANGUAGE_TABLE); - $statement = $query->execute(); + $statement = $query->executeQuery(); $lastId = (int)$statement->fetchOne(); @@ -80,7 +80,7 @@ public function insertLanguage(Language $language): int $this->setLanguageQueryParameters($query, $language); - $query->execute(); + $query->executeStatement(); return $nextId; } @@ -114,7 +114,7 @@ public function updateLanguage(Language $language): void ) ); - $query->execute(); + $query->executeStatement(); } public function loadLanguageListData(array $ids): iterable @@ -124,7 +124,7 @@ public function loadLanguageListData(array $ids): iterable ->where('id IN (:ids)') ->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } public function loadLanguageListDataByLanguageCode(array $languageCodes): iterable @@ -134,7 +134,7 @@ public function loadLanguageListDataByLanguageCode(array $languageCodes): iterab ->where('locale IN (:locale)') ->setParameter('locale', $languageCodes, Connection::PARAM_STR_ARRAY); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } /** @@ -152,7 +152,7 @@ private function createFindQuery(): QueryBuilder public function loadAllLanguagesData(): array { - return $this->createFindQuery()->execute()->fetchAll(); + return $this->createFindQuery()->executeQuery()->fetchAll(); } public function deleteLanguage(int $id): void @@ -167,7 +167,7 @@ public function deleteLanguage(int $id): void ) ); - $query->execute(); + $query->executeStatement(); } public function canDeleteLanguage(int $id): bool @@ -221,6 +221,6 @@ private function countTableData( ); } - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } } diff --git a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php index 70c51ff029..6b8a02c378 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php @@ -77,7 +77,7 @@ public function getBasicNodeData( $query->expr()->eq('t.node_id', $query->createNamedParameter($nodeId, ParameterType::INTEGER)) ); - if ($row = $query->execute()->fetch(FetchMode::ASSOCIATIVE)) { + if ($row = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE)) { return $row; } @@ -94,7 +94,7 @@ public function getNodeDataList(array $locationIds, array $translations = null, ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function getBasicNodeDataByRemoteId( @@ -107,7 +107,7 @@ public function getBasicNodeDataByRemoteId( $query->expr()->eq('t.remote_id', $query->createNamedParameter($remoteId, ParameterType::STRING)) ); - if ($row = $query->execute()->fetch(FetchMode::ASSOCIATIVE)) { + if ($row = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE)) { return $row; } @@ -135,7 +135,7 @@ public function loadLocationDataByContent(int $contentId, ?int $rootLocationId = ; } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -160,7 +160,7 @@ public function loadLocationDataByTrashContent(int $contentId, ?int $rootLocatio ; } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -213,7 +213,7 @@ public function loadParentLocationsDataForDraftContent(int $contentId): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -227,7 +227,7 @@ public function getSubtreeContent(int $sourceId, bool $onlyIds = false): array ->where($this->getSubtreeLimitationExpression($query, $sourceId)) ->orderBy('t.depth') ->addOrderBy('t.node_id'); - $statement = $query->execute(); + $statement = $query->executeQuery(); $results = $statement->fetchAll($onlyIds ? (FetchMode::COLUMN | PDO::FETCH_GROUP) : FetchMode::ASSOCIATIVE); @@ -257,7 +257,7 @@ public function getSubtreeChildrenDraftContentIds(int $sourceId): array ->setParameter('parentNode', $sourceId, ParameterType::INTEGER) ->setParameter('status', ContentInfo::STATUS_DRAFT, ParameterType::INTEGER); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchFirstColumn(); } @@ -274,7 +274,7 @@ public function getSubtreeSize(string $path): int ) ); - return (int) $query->execute()->fetchOne(); + return (int) $query->executeQuery()->fetchOne(); } /** @@ -304,7 +304,7 @@ public function getChildren(int $locationId): array $query->createPositionalParameter($locationId, ParameterType::INTEGER) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -327,7 +327,7 @@ private function getSubtreeNodesData(string $pathString): array $query->createPositionalParameter($pathString . '%', ParameterType::STRING) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(); } @@ -405,7 +405,7 @@ private function getHiddenNodeIds(int $contentObjectId): array ) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchFirstColumn(); @@ -490,7 +490,7 @@ private function moveSingleSubtreeNode( $query->createPositionalParameter($nodeId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } public function hideSubtree(string $pathString): void @@ -519,7 +519,7 @@ public function setNodeWithChildrenInvisible(string $pathString): void ) ); - $query->execute(); + $query->executeStatement(); } public function setNodeHidden(string $pathString): void @@ -543,7 +543,7 @@ private function setNodeHiddenStatus(string $pathString, bool $isHidden): void ) ); - $query->execute(); + $query->executeStatement(); } public function unHideSubtree(string $pathString): void @@ -601,7 +601,7 @@ public function setNodeWithChildrenVisible(string $pathString): void } } - $query->execute(); + $query->executeStatement(); } private function isAnyNodeInPathExplicitlyHidden(string $pathString): bool @@ -620,7 +620,7 @@ private function isAnyNodeInPathExplicitlyHidden(string $pathString): bool ) ) ); - $count = (int)$query->execute()->fetchOne(); + $count = (int)$query->executeQuery()->fetchOne(); return $count > 0; } @@ -642,7 +642,7 @@ private function loadHiddenSubtreesByPath(string $pathString): array ) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::COLUMN); } @@ -691,7 +691,7 @@ public function swap(int $locationId1, int $locationId2): bool ) ->setParameter('locationIds', [$locationId1, $locationId2], Connection::PARAM_INT_ARRAY) ; - $statement = $queryBuilder->execute(); + $statement = $queryBuilder->executeQuery(); $contentObjects = []; foreach ($statement->fetchAll(FetchMode::ASSOCIATIVE) as $row) { $row['is_main_node'] = (int)$row['main_node_id'] === (int)$row['node_id']; @@ -734,7 +734,7 @@ public function swap(int $locationId1, int $locationId2): bool ->setParameter('locationId', $locationId1); // update Location 1 entry - $queryBuilder->execute(); + $queryBuilder->executeStatement(); $queryBuilder ->setParameter('contentId', $content1data['contentobject_id']) @@ -749,7 +749,7 @@ public function swap(int $locationId1, int $locationId2): bool ->setParameter('locationId', $locationId2); // update Location 2 entry - $queryBuilder->execute(); + $queryBuilder->executeStatement(); return true; } @@ -778,7 +778,7 @@ public function create(CreateStruct $createStruct, array $parentNode): Location ) ); - $query->execute(); + $query->executeStatement(); return $location; } @@ -845,7 +845,7 @@ public function createNodeAssignment( 'is_hidden' => ParameterType::INTEGER, ] ); - $query->execute(); + $query->executeQuery(); } public function deleteNodeAssignment(int $contentId, ?int $versionNo = null): void @@ -867,7 +867,7 @@ public function deleteNodeAssignment(int $contentId, ?int $versionNo = null): vo ) ); } - $query->execute(); + $query->executeStatement(); } public function updateNodeAssignment( @@ -905,7 +905,7 @@ public function updateNodeAssignment( ) ) ); - $query->execute(); + $query->executeStatement(); } public function createLocationsFromNodeAssignments(int $contentId, int $versionNo): void @@ -937,7 +937,7 @@ public function createLocationsFromNodeAssignments(int $contentId, int $versionN ) ) ->orderBy('id'); - $statement = $query->execute(); + $statement = $query->executeStatement(); // convert all these assignments to nodes @@ -989,7 +989,7 @@ public function updateLocationsContentVersionNo(int $contentId, int $versionNo): $contentId ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -1013,7 +1013,7 @@ private function getMainNodeId(int $contentId): ?int ) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchOne(); @@ -1056,7 +1056,7 @@ public function update(UpdateStruct $location, $locationId): void $locationId ) ); - $query->execute(); + $query->executeStatement(); } public function updatePathIdentificationString($locationId, $parentLocationId, $text): void @@ -1079,7 +1079,7 @@ public function updatePathIdentificationString($locationId, $parentLocationId, $ $query->createPositionalParameter($locationId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -1098,7 +1098,7 @@ public function removeLocation($locationId): void $query->createPositionalParameter($locationId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -1145,7 +1145,7 @@ public function getFallbackMainNodeData($contentId, $locationId): array ->orderBy('node_id', 'ASC') ->setMaxResults(1); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetch(FetchMode::ASSOCIATIVE); } @@ -1163,7 +1163,7 @@ public function trashLocation(int $locationId): void $query->setValue($key, $query->createPositionalParameter($value)); } - $query->execute(); + $query->executeStatement(); $this->removeLocation($locationRow['node_id']); $this->setContentStatus((int)$locationRow['contentobject_id'], ContentInfo::STATUS_TRASHED); @@ -1210,7 +1210,7 @@ private function setContentStatus(int $contentId, int $status): void $query->createPositionalParameter($contentId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } public function loadTrashByLocation(int $locationId): array @@ -1225,7 +1225,7 @@ public function loadTrashByLocation(int $locationId): array $query->createPositionalParameter($locationId, ParameterType::INTEGER) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); if ($row = $statement->fetch(FetchMode::ASSOCIATIVE)) { return $row; @@ -1254,7 +1254,7 @@ public function listTrashed( $query->setFirstResult($offset); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -1268,7 +1268,7 @@ public function countTrashed(?CriterionInterface $criterion = null): int $this->addConditionsByCriterion($criterion, $query); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } /** @@ -1281,7 +1281,7 @@ public function cleanupTrash(): void { $query = $this->connection->createQueryBuilder(); $query->delete('ezcontentobject_trash'); - $query->execute(); + $query->executeStatement(); } public function removeElementFromTrash(int $id): void @@ -1295,7 +1295,7 @@ public function removeElementFromTrash(int $id): void $query->createPositionalParameter($id, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } public function setSectionForSubtree(string $pathString, int $sectionId): bool @@ -1313,7 +1313,7 @@ public function setSectionForSubtree(string $pathString, int $sectionId): bool $contentIds = array_map( 'intval', - $selectContentIdsQuery->execute()->fetchAll(FetchMode::COLUMN) + $selectContentIdsQuery->executeQuery()->fetchAll(FetchMode::COLUMN) ); if (empty($contentIds)) { @@ -1333,7 +1333,7 @@ public function setSectionForSubtree(string $pathString, int $sectionId): bool $contentIds ) ); - $affectedRows = $updateSectionQuery->execute(); + $affectedRows = $updateSectionQuery->executeStatement(); return $affectedRows > 0; } @@ -1352,7 +1352,7 @@ public function countLocationsByContentId(int $contentId): int $query->createPositionalParameter($contentId, ParameterType::INTEGER) ) ); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); return (int)$stmt->fetchOne(); } @@ -1378,7 +1378,7 @@ public function changeMainLocation( ) ) ; - $query->execute(); + $query->executeStatement(); // Update is_main in eznode_assignment table $this->setIsMainForContentVersionParentNodeAssignment( @@ -1394,7 +1394,7 @@ public function countAllLocations(): int // exclude absolute Root Location (not to be confused with SiteAccess Tree Root) $query->where($query->expr()->neq('node_id', 'parent_node_id')); - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int) $statement->fetch(FetchMode::COLUMN); } @@ -1427,7 +1427,7 @@ public function loadAllLocationsData(int $offset, int $limit): array ->addOrderBy('node_id', 'ASC') ; - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -1521,7 +1521,7 @@ private function setIsMainForContentVersionParentNodeAssignment( ->setParameter('content_id', $contentId, ParameterType::INTEGER) ->setParameter('version_no', $versionNo, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -1584,7 +1584,7 @@ private function insertLocationIntoContentTree( 'sort_order' => ParameterType::INTEGER, ] ); - $query->execute(); + $query->executeStatement(); $location->id = (int)$this->connection->lastInsertId(self::CONTENT_TREE_SEQ); diff --git a/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php index c96331d1b6..0626d9f4a3 100644 --- a/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php @@ -59,7 +59,7 @@ public function loadObjectStateData(int $stateId): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -80,7 +80,7 @@ public function loadObjectStateDataByIdentifier(string $identifier, int $groupId ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -95,7 +95,7 @@ public function loadObjectStateListData(int $groupId): array ) )->orderBy('state.priority', 'ASC'); - $statement = $query->execute(); + $statement = $query->executeQuery(); $rows = []; while ($row = $statement->fetch(FetchMode::ASSOCIATIVE)) { @@ -115,7 +115,7 @@ public function loadObjectStateGroupData(int $groupId): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -130,7 +130,7 @@ public function loadObjectStateGroupDataByIdentifier(string $identifier): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -143,7 +143,7 @@ public function loadObjectStateGroupListData(int $offset, int $limit): array $query->setFirstResult($offset); } - $statement = $query->execute(); + $statement = $query->executeQuery(); $rows = []; while ($row = $statement->fetch(FetchMode::ASSOCIATIVE)) { @@ -198,7 +198,7 @@ public function insertObjectState(ObjectState $objectState, int $groupId): void ] ); - $query->execute(); + $query->executeStatement(); $objectState->id = (int)$this->connection->lastInsertId(self::OBJECT_STATE_TABLE_SEQ); @@ -262,7 +262,7 @@ private function updateObjectStateCommonFields( ) ); - $query->execute(); + $query->executeStatement(); } public function updateObjectState(ObjectState $objectState): void @@ -296,7 +296,7 @@ public function deleteObjectState(int $stateId): void ) ); - $query->execute(); + $query->executeStatement(); } public function updateObjectStateLinks(int $oldStateId, int $newStateId): void @@ -316,7 +316,7 @@ public function updateObjectStateLinks(int $oldStateId, int $newStateId): void ) ; - $query->execute(); + $query->executeStatement(); } /** @@ -353,7 +353,7 @@ private function updateContentStateAssignment( ) ; - $query->execute(); + $query->executeStatement(); } public function deleteObjectStateLinks(int $stateId): void @@ -368,7 +368,7 @@ public function deleteObjectStateLinks(int $stateId): void ) ); - $query->execute(); + $query->executeStatement(); } public function insertObjectStateGroup(Group $objectStateGroup): void @@ -400,7 +400,7 @@ public function insertObjectStateGroup(Group $objectStateGroup): void ) ; - $query->execute(); + $query->executeStatement(); $objectStateGroup->id = (int)$this->connection->lastInsertId( self::OBJECT_STATE_GROUP_TABLE_SEQ @@ -441,7 +441,7 @@ public function deleteObjectStateGroup(int $groupId): void ) ; - $query->execute(); + $query->executeStatement(); } public function setContentState(int $contentId, int $groupId, int $stateId): void @@ -482,7 +482,7 @@ public function loadObjectStateDataForContent(int $contentId, int $stateGroupId) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -502,7 +502,7 @@ public function getContentCount(int $stateId): int ) ); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function updateObjectStatePriority(int $stateId, int $priority): void @@ -519,7 +519,7 @@ public function updateObjectStatePriority(int $stateId, int $priority): void ) ; - $query->execute(); + $query->executeStatement(); } /** @@ -618,7 +618,7 @@ private function insertObjectStateTranslations(ObjectState $objectState): void ] ); - $query->execute(); + $query->executeStatement(); } } @@ -639,7 +639,7 @@ private function deleteObjectStateTranslations(int $stateId): void ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -674,7 +674,7 @@ private function insertObjectStateGroupTranslations(Group $objectStateGroup): vo ->setParameter('language_id', $languageId, ParameterType::INTEGER) ->setParameter('real_language_id', $languageId & ~1, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } } @@ -693,7 +693,7 @@ private function deleteObjectStateGroupTranslations(int $groupId): void ) ); - $query->execute(); + $query->executeStatement(); } private function getMaxPriorityForObjectStatesInGroup(int $groupId): ?int @@ -711,7 +711,7 @@ private function getMaxPriorityForObjectStatesInGroup(int $groupId): ?int ) ); - $priority = $query->execute()->fetchOne(); + $priority = $query->executeQuery()->fetchOne(); return null !== $priority ? (int)$priority : null; } @@ -741,7 +741,7 @@ private function getContentStateId(int $contentId, int $groupId): ?int ) ); - $stateId = $query->execute()->fetch(FetchMode::COLUMN); + $stateId = $query->executeQuery()->fetch(FetchMode::COLUMN); return false !== $stateId ? (int)$stateId : null; } @@ -764,6 +764,6 @@ private function insertContentStateAssignment(int $contentId, int $stateId): voi ] ); - $query->execute(); + $query->executeStatement(); } } diff --git a/src/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabase.php index 4fe4541f38..4d053fa440 100644 --- a/src/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabase.php @@ -49,7 +49,7 @@ public function insertSection(string $name, string $identifier): int ] ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(Gateway::CONTENT_SECTION_SEQ); } @@ -68,7 +68,7 @@ public function updateSection(int $id, string $name, string $identifier): void ) ); - $query->execute(); + $query->executeStatement(); } public function loadSectionData(int $id): array @@ -83,7 +83,7 @@ public function loadSectionData(int $id): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -94,7 +94,7 @@ public function loadAllSectionData(): array $query->select('id', 'identifier', 'name') ->from(self::CONTENT_SECTION_TABLE); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -115,7 +115,7 @@ public function loadSectionDataByIdentifier(string $identifier): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -134,7 +134,7 @@ public function countContentObjectsInSection(int $id): int ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchOne(); } @@ -169,7 +169,7 @@ public function countPoliciesUsingSection(int $id): int ) ; - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function countRoleAssignmentsUsingSection(int $id): int @@ -193,7 +193,7 @@ public function countRoleAssignmentsUsingSection(int $id): int ) ; - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function deleteSection(int $id): void @@ -208,7 +208,7 @@ public function deleteSection(int $id): void ) ); - $query->execute(); + $query->executeStatement(); } public function assignSectionToContent(int $sectionId, int $contentId): void @@ -227,6 +227,6 @@ public function assignSectionToContent(int $sectionId, int $contentId): void ) ); - $query->execute(); + $query->executeStatement(); } } diff --git a/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php index 25ffb81d45..6ddea8e2d6 100644 --- a/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php @@ -159,7 +159,7 @@ public function insertGroup(Group $group): int ), ] ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(self::CONTENT_TYPE_GROUP_SEQ); } @@ -191,7 +191,7 @@ public function updateGroup(GroupUpdateStruct $group): void ) ); - $query->execute(); + $query->executeStatement(); } public function countTypesInGroup(int $groupId): int @@ -207,7 +207,7 @@ public function countTypesInGroup(int $groupId): int ) ); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function countGroupsForType(int $typeId, int $status): int @@ -230,7 +230,7 @@ public function countGroupsForType(int $typeId, int $status): int ) ); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function deleteGroup(int $groupId): void @@ -243,7 +243,7 @@ public function deleteGroup(int $groupId): void $query->createPositionalParameter($groupId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -289,7 +289,7 @@ private function insertTypeNameData(int $typeId, int $typeStatus, array $languag 'name' => $query->createPositionalParameter($name, ParameterType::STRING), ] ); - $query->execute(); + $query->executeStatement(); } } @@ -370,7 +370,7 @@ public function insertType(Type $type, ?int $typeId = null): int $query->setParameter('created', $type->created, ParameterType::INTEGER); $query->setParameter('creator_id', $type->creatorId, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); if (empty($typeId)) { $typeId = $this->sharedGateway->getLastInsertedId(self::CONTENT_TYPE_SEQ); @@ -445,7 +445,7 @@ public function insertGroupAssignment(int $groupId, int $typeId, int $status): v ] ); - $query->execute(); + $query->executeStatement(); } public function deleteGroupAssignment(int $groupId, int $typeId, int $status): void @@ -472,7 +472,7 @@ public function deleteGroupAssignment(int $groupId, int $typeId, int $status): v $query->createPositionalParameter($groupId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } public function loadGroupData(array $groupIds): array @@ -482,7 +482,7 @@ public function loadGroupData(array $groupIds): array ->where($query->expr()->in('id', ':ids')) ->setParameter('ids', $groupIds, Connection::PARAM_INT_ARRAY); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } public function loadGroupDataByIdentifier(string $identifier): array @@ -495,7 +495,7 @@ public function loadGroupDataByIdentifier(string $identifier): array ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function loadAllGroupsData(): array @@ -509,7 +509,7 @@ public function loadAllGroupsData(): array ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -542,7 +542,7 @@ public function loadTypesDataForGroup(int $groupId, int $status): array ->setParameter('gid', $groupId, ParameterType::INTEGER) ->setParameter('version', $status, ParameterType::INTEGER); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } public function insertFieldDefinition( @@ -586,7 +586,7 @@ public function insertFieldDefinition( ->setParameter($columnName, $columnValue, $parameterType); } - $query->execute(); + $query->executeStatement(); $fieldDefinitionId = $fieldDefinition->id ?? $this->sharedGateway->getLastInsertedId( self::FIELD_DEFINITION_SEQ @@ -630,7 +630,7 @@ private function insertFieldDefinitionMultilingualData( ->setParameter('status', $status, ParameterType::INTEGER) ->setParameter('language_id', $multilingualData->languageId, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -732,7 +732,7 @@ public function loadFieldDefinition(int $id, int $status): array ) ); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); return $stmt->fetchAll(FetchMode::ASSOCIATIVE); } @@ -751,7 +751,7 @@ public function deleteFieldDefinition( ->setParameter('field_definition_id', $fieldDefinitionId, ParameterType::INTEGER) ->setParameter('status', $status, ParameterType::INTEGER); - $deleteQuery->execute(); + $deleteQuery->executeStatement(); // Delete legacy Field Definition data $query = $this->connection->createQueryBuilder(); @@ -772,7 +772,7 @@ public function deleteFieldDefinition( ) ; - $query->execute(); + $query->executeStatement(); } public function updateFieldDefinition( @@ -802,7 +802,7 @@ public function updateFieldDefinition( ); } - $query->execute(); + $query->executeStatement(); foreach ($storageFieldDef->multilingualData as $data) { $dataExists = $this->fieldDefinitionMultilingualDataExist( @@ -844,7 +844,7 @@ private function fieldDefinitionMultilingualDataExist( ->setParameter('status', $status, ParameterType::INTEGER) ->setParameter('language_id', $languageId, ParameterType::INTEGER); - return 0 < (int)$existQuery->execute()->fetchOne(); + return 0 < (int)$existQuery->executeQuery()->fetchOne(); } private function updateFieldDefinitionMultilingualData( @@ -870,7 +870,7 @@ private function updateFieldDefinitionMultilingualData( ->setParameter('status', $status, ParameterType::INTEGER) ->setParameter('languageId', $multilingualData->languageId, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } /** @@ -894,7 +894,7 @@ private function deleteTypeNameData(int $typeId, int $typeStatus): void $query->createPositionalParameter($typeStatus, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } public function updateType(int $typeId, int $status, Type $type): void @@ -928,7 +928,7 @@ public function updateType(int $typeId, int $status, Type $type): void ) ); - $query->execute(); + $query->executeStatement(); $this->deleteTypeNameData($typeId, $status); $this->insertTypeNameData($typeId, $status, $type->name); @@ -943,7 +943,7 @@ public function loadTypesListData(array $typeIds): array ->andWhere($query->expr()->eq('c.version', Type::STATUS_DEFINED)) ->setParameter('ids', $typeIds, Connection::PARAM_INT_ARRAY); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } public function loadTypesDataByFieldDefinitionIdentifier(string $identifier): array @@ -957,7 +957,7 @@ public function loadTypesDataByFieldDefinitionIdentifier(string $identifier): ar ) ); - return $query->execute()->fetchAllAssociative(); + return $query->executeQuery()->fetchAllAssociative(); } public function loadTypeData(int $typeId, int $status): array @@ -970,7 +970,7 @@ public function loadTypeData(int $typeId, int $status): array ->setParameter('id', $typeId, ParameterType::INTEGER) ->setParameter('version', $status, ParameterType::INTEGER); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } public function loadTypeDataByIdentifier(string $identifier, int $status): array @@ -983,7 +983,7 @@ public function loadTypeDataByIdentifier(string $identifier, int $status): array ->setParameter('identifier', $identifier, ParameterType::STRING) ->setParameter('version', $status, ParameterType::INTEGER); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } public function loadTypeDataByRemoteId(string $remoteId, int $status): array @@ -995,7 +995,7 @@ public function loadTypeDataByRemoteId(string $remoteId, int $status): array ->setParameter('remote', $remoteId, ParameterType::STRING) ->setParameter('version', $status, ParameterType::INTEGER); - return $query->execute()->fetchAll(); + return $query->executeQuery()->fetchAll(); } /** @@ -1104,7 +1104,7 @@ public function countInstancesOfType(int $typeId): int ) ); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); return (int)$stmt->fetchOne(); } @@ -1129,7 +1129,7 @@ public function deleteFieldDefinitionsForType(int $typeId, int $status): void ->setParameter('content_type_id', $typeId, ParameterType::INTEGER) ->setParameter('status', $status, ParameterType::INTEGER); - $deleteQuery->execute(); + $deleteQuery->executeStatement(); $query = $this->connection->createQueryBuilder(); $expr = $query->expr(); @@ -1148,7 +1148,7 @@ public function deleteFieldDefinitionsForType(int $typeId, int $status): void ) ); - $query->execute(); + $query->executeStatement(); } public function delete(int $typeId, int $status): void @@ -1176,7 +1176,7 @@ public function deleteType(int $typeId, int $status): void ) ) ); - $query->execute(); + $query->executeStatement(); } public function deleteGroupAssignmentsForType(int $typeId, int $status): void @@ -1195,7 +1195,7 @@ public function deleteGroupAssignmentsForType(int $typeId, int $status): void $query->createPositionalParameter($status, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -1258,7 +1258,7 @@ public function internalChangeContentTypeStatus( ) ); - $query->execute(); + $query->executeStatement(); } public function publishTypeAndFields(int $typeId, int $sourceStatus, int $targetStatus): void @@ -1321,7 +1321,7 @@ public function publishTypeAndFields(int $typeId, int $sourceStatus, int $target ->setParameter('target_status', $targetStatus, ParameterType::INTEGER) ->setParameter('source_status', $sourceStatus, ParameterType::INTEGER); - $mlDataPublishQuery->execute(); + $mlDataPublishQuery->executeStatement(); } public function getSearchableFieldMapData(): array @@ -1343,7 +1343,7 @@ public function getSearchableFieldMapData(): array ) ); - $statement = $query->execute($query); + $statement = $query->executeQuery($query); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -1367,7 +1367,7 @@ public function removeFieldDefinitionTranslation( ->setParameter('status', $status, ParameterType::INTEGER) ->setParameter('language_id', $languageId, ParameterType::INTEGER); - $deleteQuery->execute(); + $deleteQuery->executeStatement(); } /** @@ -1386,7 +1386,7 @@ public function removeByUserAndVersion(int $userId, int $version): void try { $this->connection->beginTransaction(); - $queryBuilder->execute(); + $queryBuilder->executeStatement(); $this->cleanupAssociations(); $this->connection->commit(); diff --git a/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php index da27085d79..1ab95dce11 100644 --- a/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php @@ -94,7 +94,7 @@ public function loadAllLocationEntries(int $locationId): array ->setParameter('action', "eznode:{$locationId}", ParameterType::STRING) ->setParameter('is_original', 1, ParameterType::INTEGER); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function loadLocationEntries( @@ -153,7 +153,7 @@ public function loadLocationEntries( ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -223,7 +223,7 @@ public function listGlobalEntries( ) ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -243,7 +243,7 @@ public function isRootEntry(int $id): bool $query->createPositionalParameter($id, ParameterType::INTEGER) ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $row = $statement->fetch(FetchMode::ASSOCIATIVE); @@ -311,7 +311,7 @@ public function cleanupAfterPublish( ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $row = $statement->fetch(FetchMode::ASSOCIATIVE); @@ -388,7 +388,7 @@ public function historizeBeforeSwap(string $action, int $languageMask): void ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -435,7 +435,7 @@ private function historize(int $parentId, string $textMD5, int $newId): void ) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -477,7 +477,7 @@ private function removeTranslation(int $parentId, string $textMD5, int $language ) ) ; - $query->execute(); + $query->executeStatement(); } public function historizeId(int $id, int $link): void @@ -516,7 +516,7 @@ public function historizeId(int $id, int $link): void ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $rows = $statement->fetchAll(FetchMode::ASSOCIATIVE); @@ -543,7 +543,7 @@ public function reparent(int $oldParentId, int $newParentId): void ) ); - $query->execute(); + $query->executeStatement(); } public function updateRow(int $parentId, string $textMD5, array $values): void @@ -573,7 +573,7 @@ public function updateRow(int $parentId, string $textMD5, array $values): void $query->createNamedParameter($textMD5, ParameterType::STRING, ':text_md5') ) ); - $query->execute(); + $query->executeStatement(); } public function insertRow(array $values): int @@ -618,7 +618,7 @@ public function insertRow(array $values): int ) ); } - $query->execute(); + $query->executeStatement(); return (int)$values['id']; } @@ -636,7 +636,7 @@ public function getNextId(): int ] ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(self::INCR_TABLE_SEQ); } @@ -665,7 +665,7 @@ public function loadRow(int $parentId, string $textMD5): array ) ); - $result = $query->execute()->fetch(FetchMode::ASSOCIATIVE); + $result = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE); return false !== $result ? $result : []; } @@ -717,7 +717,7 @@ static function (string $columnName) use ($tableAlias): string { } $query->setMaxResults(1); - $result = $query->execute()->fetch(FetchMode::ASSOCIATIVE); + $result = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE); return false !== $result ? $result : []; } @@ -758,7 +758,7 @@ public function loadAutogeneratedEntry(string $action, ?int $parentId = null): a ); } - $entry = $query->execute()->fetch(FetchMode::ASSOCIATIVE); + $entry = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE); return false !== $entry ? $entry : []; } @@ -782,7 +782,7 @@ public function loadPathData(int $id): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $rows = $statement->fetchAll(FetchMode::ASSOCIATIVE); if (empty($rows)) { @@ -852,7 +852,7 @@ public function loadPathDataByHierarchy(array $hierarchyData): array $query->expr()->or(...$hierarchyConditions) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $rows = $statement->fetchAll(FetchMode::ASSOCIATIVE); $rowsMap = []; @@ -900,7 +900,7 @@ public function removeCustomAlias(int $parentId, string $textMD5): bool ) ); - return $query->execute() === 1; + return $query->executeStatement() === 1; } public function remove(string $action, ?int $id = null): void @@ -935,7 +935,7 @@ public function remove(string $action, ?int $id = null): void ); } - $query->execute(); + $query->executeStatement(); } public function loadAutogeneratedEntries(int $parentId, bool $includeHistory = false): array @@ -979,7 +979,7 @@ public function loadAutogeneratedEntries(int $parentId, bool $includeHistory = f ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -997,7 +997,7 @@ public function getLocationContentMainLanguageId(int $locationId): int ) ->setParameter('locationId', $locationId, ParameterType::INTEGER); - $statement = $queryBuilder->execute(); + $statement = $queryBuilder->executeQuery(); $languageId = $statement->fetchOne(); if ($languageId === false) { @@ -1016,7 +1016,7 @@ public function bulkRemoveTranslation(int $languageId, array $actions): void ->set('lang_mask', 'lang_mask & ~ ' . $languageId) ->where('action IN (:actions)') ->setParameter('actions', $actions, Connection::PARAM_STR_ARRAY); - $query->execute(); + $query->executeStatement(); // cleanup: delete single language rows (including alwaysAvailable) $query = $this->connection->createQueryBuilder(); @@ -1025,7 +1025,7 @@ public function bulkRemoveTranslation(int $languageId, array $actions): void ->where('action IN (:actions)') ->andWhere('lang_mask IN (0, 1)') ->setParameter('actions', $actions, Connection::PARAM_STR_ARRAY); - $query->execute(); + $query->executeStatement(); } public function archiveUrlAliasesForDeletedTranslations( @@ -1102,7 +1102,7 @@ private function loadLocationEntriesMatchingMultipleLanguages( ->setParameter('action', 'eznode:' . $locationId) ->setParameter('languageMask', $languageMask); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -1145,7 +1145,7 @@ public function deleteUrlAliasesWithoutLocation(): int sprintf('NOT EXISTS (%s)', $subQuery->getSQL()) ); - return $deleteQuery->execute(); + return $deleteQuery->executeStatement(); } public function deleteUrlAliasesWithoutParent(): int @@ -1168,7 +1168,7 @@ public function deleteUrlAliasesWithoutParent(): int ) ); - return $query->execute(); + return $query->executeStatement(); } public function deleteUrlAliasesWithBrokenLink(): int @@ -1188,7 +1188,7 @@ public function deleteUrlAliasesWithBrokenLink(): int ) ); - return (int)$query->execute(); + return (int)$query->executeStatement(); } public function repairBrokenUrlAliasesForLocation(int $locationId): void @@ -1250,7 +1250,7 @@ public function repairBrokenUrlAliasesForLocation(int $locationId): void ->setParameter('textMD5', $urlAliasData['text_md5']); try { - $updateQueryBuilder->execute(); + $updateQueryBuilder->executeStatement(); } catch (UniqueConstraintViolationException $e) { // edge case: if such row already exists, there's no way to restore history $this->deleteRow((int) $urlAliasData['parent'], $urlAliasData['text_md5']); @@ -1306,7 +1306,7 @@ public function deleteUrlNopAliasesWithoutChildren(): int ) ->setParameter('actionType', self::NOP); - return $queryBuilder->execute(); + return $queryBuilder->executeStatement(); } /** @@ -1332,7 +1332,7 @@ public function getAllChildrenAliases(int $parentId): array ) ); - return $queryBuilder->execute()->fetchAll(); + return $queryBuilder->executeQuery()->fetchAll(); } /** @@ -1419,7 +1419,7 @@ private function getUrlAliasesForLocation(int $locationId): array ) ); - return $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -1445,6 +1445,6 @@ private function deleteRow(int $parentId, string $textMD5): int ) ; - return $queryBuilder->execute(); + return $queryBuilder->executeStatement(); } } diff --git a/src/lib/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php index 272258754c..5fb94a06f3 100644 --- a/src/lib/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php @@ -74,7 +74,7 @@ public function insertUrlWildcard(UrlWildcard $urlWildcard): int ] ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(self::URL_WILDCARD_SEQ); } @@ -119,7 +119,7 @@ public function updateUrlWildcard( ) ); - $query->execute(); + $query->executeStatement(); } public function deleteUrlWildcard(int $id): void @@ -133,7 +133,7 @@ public function deleteUrlWildcard(int $id): void $query->createPositionalParameter($id, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } private function buildLoadUrlWildcardDataQuery(): QueryBuilder @@ -156,7 +156,7 @@ public function loadUrlWildcardData(int $id): array $query->createPositionalParameter($id, ParameterType::INTEGER) ) ); - $result = $query->execute()->fetch(FetchMode::ASSOCIATIVE); + $result = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE); return false !== $result ? $result : []; } @@ -168,7 +168,7 @@ public function loadUrlWildcardsData(int $offset = 0, int $limit = -1): array ->setMaxResults($limit > 0 ? $limit : self::MAX_LIMIT) ->setFirstResult($offset); - $stmt = $query->execute(); + $stmt = $query->executeQuery(); return $stmt->fetchAll(FetchMode::ASSOCIATIVE); } @@ -206,7 +206,7 @@ public function find( $query->addOrderBy($sortClause->target, $this->getQuerySortingDirection($sortClause->direction)); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return [ 'count' => $count, @@ -226,7 +226,7 @@ public function loadUrlWildcardBySourceUrl(string $sourceUrl): array ) ); - $result = $query->execute()->fetch(FetchMode::ASSOCIATIVE); + $result = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE); return false !== $result ? $result : []; } @@ -238,7 +238,7 @@ public function countAll(): int ->select($this->connection->getDatabasePlatform()->getCountExpression('id')) ->from(self::URL_WILDCARD_TABLE); - return (int) $query->execute()->fetchOne(); + return (int) $query->executeQuery()->fetchOne(); } /** @@ -256,7 +256,7 @@ protected function doCount(Criterion $criterion): int ->from(self::URL_WILDCARD_TABLE, 'url_wildcard') ->where($this->criteriaConverter->convertCriteria($query, $criterion)); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } /** diff --git a/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php b/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php index 439b34ffdf..3b2afb20a0 100644 --- a/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php +++ b/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php @@ -94,7 +94,7 @@ public function count(FilteringCriterion $criterion): int $criterion ); - return (int)$query->execute()->fetch(FetchMode::COLUMN); + return (int)$query->executeQuery()->fetch(FetchMode::COLUMN); } public function find( @@ -117,7 +117,7 @@ public function find( $wrappedQuery->setMaxResults($limit); } - $resultStatement = $wrappedQuery->execute(); + $resultStatement = $wrappedQuery->executeQuery(); while (false !== ($row = $resultStatement->fetch(FetchMode::ASSOCIATIVE))) { $contentId = (int)$row['content_id']; $versionNo = (int)$row['content_version_no']; @@ -229,7 +229,7 @@ private function bulkFetchVersionNames(FilteringQueryBuilder $query): array ->setFirstResult(null) ->resetQueryPart('orderBy'); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } private function bulkFetchFieldValues(FilteringQueryBuilder $query): array @@ -265,7 +265,7 @@ private function bulkFetchFieldValues(FilteringQueryBuilder $query): array ->setFirstResult(null) ->resetQueryPart('orderBy'); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } private function getColumns(): Traversable diff --git a/src/lib/Persistence/Legacy/Filter/Gateway/Location/Doctrine/DoctrineGateway.php b/src/lib/Persistence/Legacy/Filter/Gateway/Location/Doctrine/DoctrineGateway.php index 25e36fe8d7..30805df3f5 100644 --- a/src/lib/Persistence/Legacy/Filter/Gateway/Location/Doctrine/DoctrineGateway.php +++ b/src/lib/Persistence/Legacy/Filter/Gateway/Location/Doctrine/DoctrineGateway.php @@ -60,7 +60,7 @@ public function count(FilteringCriterion $criterion): int $query->select($this->getDatabasePlatform()->getCountExpression('DISTINCT location.node_id')); - return (int)$query->execute()->fetch(FetchMode::COLUMN); + return (int)$query->executeQuery()->fetch(FetchMode::COLUMN); } public function find( @@ -77,7 +77,7 @@ public function find( $query->setMaxResults($limit); } - $resultStatement = $query->execute(); + $resultStatement = $query->executeQuery(); while (false !== ($row = $resultStatement->fetch(FetchMode::ASSOCIATIVE))) { yield $row; diff --git a/src/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabase.php index a745b28e95..75206e7cf3 100644 --- a/src/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabase.php @@ -57,7 +57,7 @@ public function insert(CreateStruct $createStruct): int ->setParameter('type', $createStruct->type, PDO::PARAM_STR) ->setParameter('data', json_encode($createStruct->data), PDO::PARAM_STR); - $query->execute(); + $query->executeStatement(); return (int) $this->connection->lastInsertId(); } @@ -75,7 +75,7 @@ public function getNotificationById(int $notificationId): array $query->setParameter('id', $notificationId, PDO::PARAM_INT); - return $query->execute()->fetchAll(PDO::FETCH_ASSOC); + return $query->executeQuery()->fetchAll(PDO::FETCH_ASSOC); } /** @@ -96,7 +96,7 @@ public function updateNotification(Notification $notification): void ->setParameter('is_pending', $notification->isPending, PDO::PARAM_BOOL) ->setParameter('id', $notification->id, PDO::PARAM_INT); - $query->execute(); + $query->executeStatement(); } public function countUserNotifications(int $userId): int @@ -109,7 +109,7 @@ public function countUserNotifications(int $userId): int ->setParameter('user_id', $userId, PDO::PARAM_INT); /** @phpstan-var int<0, max> */ - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } /** @@ -127,7 +127,7 @@ public function countUserPendingNotifications(int $userId): int ->setParameter('is_pending', true, PDO::PARAM_BOOL) ->setParameter('user_id', $userId, PDO::PARAM_INT); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } /** @@ -149,7 +149,7 @@ public function loadUserNotifications(int $userId, int $offset = 0, int $limit = $query->orderBy(self::COLUMN_ID, 'DESC'); $query->setParameter('user_id', $userId, PDO::PARAM_INT); - return $query->execute()->fetchAll(PDO::FETCH_ASSOC); + return $query->executeQuery()->fetchAll(PDO::FETCH_ASSOC); } /** @@ -163,7 +163,7 @@ public function delete(int $notificationId): void ->where($query->expr()->eq(self::COLUMN_ID, ':id')) ->setParameter('id', $notificationId, PDO::PARAM_INT); - $query->execute(); + $query->executeStatement(); } /** diff --git a/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php index 90fdfcab2f..3b713579a8 100644 --- a/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php @@ -40,7 +40,7 @@ public function insertSetting(string $group, string $identifier, string $seriali ] ); - $query->execute(); + $query->executeStatement(); return (int)$this->connection->lastInsertId(Gateway::SETTING_SEQ); } @@ -62,7 +62,7 @@ public function updateSetting(string $group, string $identifier, string $seriali ) ); - $query->execute(); + $query->executeStatement(); } public function loadSetting(string $group, string $identifier): ?array @@ -86,7 +86,7 @@ public function loadSetting(string $group, string $identifier): ?array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchAssociative(); if (false === $result) { @@ -113,7 +113,7 @@ public function loadSettingById(int $id): ?array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchAssociative(); if (false === $result) { @@ -139,6 +139,6 @@ public function deleteSetting(string $group, string $identifier): void ) ); - $query->execute(); + $query->executeStatement(); } } diff --git a/src/lib/Persistence/Legacy/Token/Gateway/Token/Doctrine/DoctrineGateway.php b/src/lib/Persistence/Legacy/Token/Gateway/Token/Doctrine/DoctrineGateway.php index a49f63a2b6..089f68aead 100644 --- a/src/lib/Persistence/Legacy/Token/Gateway/Token/Doctrine/DoctrineGateway.php +++ b/src/lib/Persistence/Legacy/Token/Gateway/Token/Doctrine/DoctrineGateway.php @@ -148,7 +148,7 @@ public function deleteExpired(?int $typeId = null): void $query->setParameter('type_id', $typeId, ParameterType::INTEGER); } - $query->execute(); + $query->executeStatement(); } public function getToken( @@ -157,7 +157,7 @@ public function getToken( ?string $identifier = null ): array { $query = $this->getTokenSelectQueryBuilder($tokenType, $token, $identifier); - $row = $query->execute()->fetchAssociative(); + $row = $query->executeQuery()->fetchAssociative(); if (false === $row) { throw new NotFound('token', "token: $token, type: $tokenType, identifier: $identifier"); @@ -181,7 +181,7 @@ public function getTokenById(int $tokenId): array $query->setParameter('token_id', $tokenId, ParameterType::INTEGER); - $row = $query->execute()->fetchAssociative(); + $row = $query->executeQuery()->fetchAssociative(); if (false === $row) { throw new NotFound('token', "id: $tokenId"); diff --git a/src/lib/Persistence/Legacy/Token/Gateway/TokenType/Doctrine/DoctrineGateway.php b/src/lib/Persistence/Legacy/Token/Gateway/TokenType/Doctrine/DoctrineGateway.php index 0655b03d75..149e3d9cb5 100644 --- a/src/lib/Persistence/Legacy/Token/Gateway/TokenType/Doctrine/DoctrineGateway.php +++ b/src/lib/Persistence/Legacy/Token/Gateway/TokenType/Doctrine/DoctrineGateway.php @@ -85,7 +85,7 @@ public function getTypeById(int $typeId): array $query->setParameter('type_id', $typeId, ParameterType::INTEGER); - $row = $query->execute()->fetchAssociative(); + $row = $query->executeQuery()->fetchAssociative(); if (false === $row) { throw new NotFound('token_type', "id: $typeId"); @@ -109,7 +109,7 @@ public function getTypeByIdentifier(string $identifier): array $query->setParameter('identifier', $identifier, ParameterType::STRING); - $row = $query->execute()->fetchAssociative(); + $row = $query->executeQuery()->fetchAssociative(); if (false === $row) { throw new NotFound('token_type', "identifier: $identifier"); diff --git a/src/lib/Persistence/Legacy/URL/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/URL/Gateway/DoctrineDatabase.php index 2f3fb9e8f0..2155709396 100644 --- a/src/lib/Persistence/Legacy/URL/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/URL/Gateway/DoctrineDatabase.php @@ -88,7 +88,7 @@ public function find(Criterion $criterion, $offset, $limit, array $sortClauses = $query->addOrderBy($column, $this->getQuerySortingDirection($sortClause->direction)); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return [ 'count' => $count, @@ -131,7 +131,7 @@ public function findUsages($id): array ) ); - return $query->execute()->fetchAll(FetchMode::COLUMN); + return $query->executeQuery()->fetchAll(FetchMode::COLUMN); } /** @@ -168,7 +168,7 @@ public function updateUrl(URL $url) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -184,7 +184,7 @@ public function loadUrlData($id): array ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -200,7 +200,7 @@ public function loadUrlDataByUrl($url): array ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -216,7 +216,7 @@ protected function doCount(Criterion $criterion): int ->from(self::URL_TABLE, 'url') ->where($this->criteriaConverter->convertCriteria($query, $criterion)); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } /** diff --git a/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php index 8b70e88c37..d7e9bd2540 100644 --- a/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php @@ -52,7 +52,7 @@ public function load(int $userId): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -73,7 +73,7 @@ public function loadByLogin(string $login): array ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function loadByEmail(string $email): array @@ -86,7 +86,7 @@ public function loadByEmail(string $email): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -117,7 +117,7 @@ public function loadUserByToken(string $hash): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -142,7 +142,7 @@ public function updateUserPassword(User $user): void ) ->setParameter('userId', $user->id, ParameterType::INTEGER); - $queryBuilder->execute(); + $queryBuilder->executeStatement(); } public function updateUserToken(UserTokenUpdateStruct $userTokenUpdateStruct): void @@ -170,7 +170,7 @@ public function updateUserToken(UserTokenUpdateStruct $userTokenUpdateStruct): v $query->setParameter('time', $userTokenUpdateStruct->time, ParameterType::INTEGER); $query->setParameter('user_id', $userTokenUpdateStruct->userId, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } public function expireUserToken(string $hash): void @@ -187,7 +187,7 @@ public function expireUserToken(string $hash): void $query->createPositionalParameter($hash, ParameterType::STRING) ) ); - $query->execute(); + $query->executeStatement(); } public function assignRole(int $contentId, int $roleId, array $limitation): void @@ -217,7 +217,7 @@ public function assignRole(int $contentId, int $roleId, array $limitation): void ), ] ); - $query->execute(); + $query->executeStatement(); } } } @@ -240,7 +240,7 @@ public function removeRole(int $contentId, int $roleId): void $query->createPositionalParameter($roleId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } public function removeRoleAssignmentById(int $roleAssignmentId): void @@ -254,7 +254,7 @@ public function removeRoleAssignmentById(int $roleAssignmentId): void $query->createPositionalParameter($roleAssignmentId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } private function getLoadUserQueryBuilder(): QueryBuilder @@ -303,6 +303,6 @@ private function userHasToken(int $userId): bool ) ); - return !empty($query->execute()->fetch(FetchMode::ASSOCIATIVE)); + return !empty($query->executeQuery()->fetch(FetchMode::ASSOCIATIVE)); } } diff --git a/src/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabase.php index 11330c7d65..a9ee9ac8bd 100644 --- a/src/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabase.php @@ -76,7 +76,7 @@ public function createRole(Role $role): Role ), ] ); - $query->execute(); + $query->executeStatement(); if (!isset($role->id) || (int)$role->id < 1 || $role->status === Role::STATUS_DRAFT) { $role->id = (int)$this->connection->lastInsertId(self::ROLE_SEQ); @@ -109,7 +109,7 @@ public function copyRole(Role $role): Role ), ] ); - $query->execute(); + $query->executeStatement(); $role->id = (int)$this->connection->lastInsertId(self::ROLE_SEQ); @@ -160,7 +160,7 @@ public function loadRole(int $roleId, int $status = Role::STATUS_DEFINED): array ->addOrderBy('l.identifier', 'ASC') ->addOrderBy('v.value', 'ASC'); - return $query->execute()->fetchAllAssociative(); + return $query->executeQuery()->fetchAllAssociative(); } /** @@ -186,7 +186,7 @@ public function loadRoleByIdentifier( ->addOrderBy('l.identifier', 'ASC') ->addOrderBy('v.value', 'ASC'); - return $query->execute()->fetchAllAssociative(); + return $query->executeQuery()->fetchAllAssociative(); } public function loadRoleDraftByRoleId(int $roleId): array @@ -202,7 +202,7 @@ public function loadRoleDraftByRoleId(int $roleId): array ) ->orderBy('p.id', 'ASC'); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -214,7 +214,7 @@ public function loadRoles(int $status = Role::STATUS_DEFINED): array $this->buildRoleDraftQueryConstraint($status, $query) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -260,7 +260,7 @@ public function loadRolesForContentObjects( ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function loadRoleAssignment(int $roleAssignmentId): array @@ -281,7 +281,7 @@ public function loadRoleAssignment(int $roleAssignmentId): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -317,7 +317,7 @@ public function loadRoleAssignmentsByGroupId(int $groupId, bool $inherited = fal ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -340,7 +340,7 @@ public function loadRoleAssignmentsByRoleId(int $roleId): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } @@ -369,7 +369,7 @@ public function loadRoleAssignmentsByRoleIdWithOffsetAndLimit(int $roleId, int $ } return $query - ->execute() + ->executeQuery() ->fetchAllAssociative(); } @@ -384,7 +384,7 @@ public function countRoleAssignments(int $roleId): int $roleId ); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } /** @@ -450,7 +450,7 @@ private function fetchUserGroups(int $userId): array ) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::COLUMN); } @@ -470,7 +470,7 @@ public function updateRole(RoleUpdateStruct $role): void $query->createPositionalParameter($role->id, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } public function deleteRole(int $roleId, int $status = Role::STATUS_DEFINED): void @@ -492,7 +492,7 @@ public function deleteRole(int $roleId, int $status = Role::STATUS_DEFINED): voi if ($status !== Role::STATUS_DRAFT) { $this->deleteRoleAssignments($roleId); } - $query->execute(); + $query->executeStatement(); } public function publishRoleDraft(int $roleDraftId, ?int $originalRoleId = null): void @@ -523,7 +523,7 @@ public function addPolicy(int $roleId, Policy $policy): Policy 'role_id' => $query->createPositionalParameter($roleId, ParameterType::INTEGER), ] ); - $query->execute(); + $query->executeStatement(); $policy->id = (int)$this->connection->lastInsertId(self::POLICY_SEQ); $policy->roleId = $roleId; @@ -556,7 +556,7 @@ public function addPolicyLimitations(int $policyId, array $limitations): void ), ] ); - $query->execute(); + $query->executeStatement(); $limitationId = (int)$this->connection->lastInsertId(self::POLICY_LIMITATION_SEQ); @@ -576,7 +576,7 @@ public function addPolicyLimitations(int $policyId, array $limitations): void ), ] ); - $query->execute(); + $query->executeStatement(); } } } @@ -594,7 +594,7 @@ public function removePolicy(int $policyId): void $query->createPositionalParameter($policyId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -614,7 +614,7 @@ private function deletePolicyLimitations(array $limitationIds): void ) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -634,7 +634,7 @@ private function deletePolicyLimitationValues(array $limitationValueIds): void ) ) ); - $query->execute(); + $query->executeStatement(); } private function loadPolicyLimitationValues(int $policyId): array @@ -655,7 +655,7 @@ private function loadPolicyLimitationValues(int $policyId): array ) ); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } public function removePolicyLimitations(int $policyId): void @@ -694,7 +694,7 @@ private function deleteRoleAssignments(int $roleId): void $query->createPositionalParameter($roleId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } /** @@ -717,7 +717,7 @@ private function getAncestorLocationIdsForUser(int $userId): array ) ); - $paths = $query->execute()->fetchAll(FetchMode::COLUMN); + $paths = $query->executeQuery()->fetchAll(FetchMode::COLUMN); $nodeIds = array_unique( array_reduce( array_map( @@ -778,7 +778,7 @@ private function markRoleAsPublished(int $roleDraftId, ?int $originalRoleId): vo $query->createPositionalParameter($roleDraftId, ParameterType::INTEGER) ) ); - $query->execute(); + $query->executeStatement(); } private function publishRolePolicies(int $roleDraftId, ?int $originalRoleId): void @@ -804,6 +804,6 @@ private function publishRolePolicies(int $roleDraftId, ?int $originalRoleId): vo $policyQuery->createPositionalParameter($roleDraftId, ParameterType::INTEGER) ) ); - $policyQuery->execute(); + $policyQuery->executeStatement(); } } diff --git a/src/lib/Persistence/Legacy/User/Role/LimitationHandler/ObjectStateHandler.php b/src/lib/Persistence/Legacy/User/Role/LimitationHandler/ObjectStateHandler.php index b6dee68148..d1d17ad1a1 100644 --- a/src/lib/Persistence/Legacy/User/Role/LimitationHandler/ObjectStateHandler.php +++ b/src/lib/Persistence/Legacy/User/Role/LimitationHandler/ObjectStateHandler.php @@ -122,7 +122,7 @@ protected function getGroupMap(array $limitIds = null): array ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); $map = []; $groupValues = $statement->fetchAll(FetchMode::ASSOCIATIVE); diff --git a/src/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabase.php index ed5e6eead0..b90d1535d7 100644 --- a/src/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabase.php @@ -51,7 +51,7 @@ public function setUserPreference(UserPreferenceSetStruct $userPreference): int ->setParameter('id', $currentUserPreferenceId, ParameterType::INTEGER) ->setParameter('value', $userPreference->value, ParameterType::STRING); - $query->execute(); + $query->executeStatement(); return $currentUserPreferenceId; } @@ -67,7 +67,7 @@ public function setUserPreference(UserPreferenceSetStruct $userPreference): int ->setParameter('user_id', $userPreference->userId, ParameterType::INTEGER) ->setParameter('value', $userPreference->value, ParameterType::STRING); - $query->execute(); + $query->executeStatement(); return (int) $this->connection->lastInsertId(); } @@ -84,7 +84,7 @@ public function getUserPreferenceByUserIdAndName(int $userId, string $name): arr $query->setParameter('userId', $userId, ParameterType::INTEGER); $query->setParameter('name', $name, ParameterType::STRING); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -106,7 +106,7 @@ public function loadUserPreferences(int $userId, int $offset = 0, int $limit = - $query->orderBy(self::COLUMN_ID, 'ASC'); $query->setParameter('user_id', $userId, ParameterType::INTEGER); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -123,7 +123,7 @@ public function countUserPreferences(int $userId): int ->where($query->expr()->eq(self::COLUMN_USER_ID, ':user_id')) ->setParameter('user_id', $userId, ParameterType::INTEGER); - return (int) $query->execute()->fetchOne(); + return (int) $query->executeQuery()->fetchOne(); } private function getColumns(): array diff --git a/src/lib/Search/Common/Indexer.php b/src/lib/Search/Common/Indexer.php index 064af65d46..14233d4fa9 100644 --- a/src/lib/Search/Common/Indexer.php +++ b/src/lib/Search/Common/Indexer.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Result; use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; use Ibexa\Contracts\Core\Persistence\Handler as PersistenceHandler; use Ibexa\Contracts\Core\Search\Handler as SearchHandler; @@ -50,7 +51,7 @@ public function __construct( * * @param array $fields fields to select */ - protected function getContentDbFieldsStmt(array $fields): Statement + protected function getContentDbFieldsStmt(array $fields): Result { $query = $this->connection->createQueryBuilder(); $query @@ -58,6 +59,6 @@ protected function getContentDbFieldsStmt(array $fields): Statement ->from(ContentGateway::CONTENT_ITEM_TABLE) ->where($query->expr()->eq('status', ContentInfo::STATUS_PUBLISHED)); - return $query->execute(); + return $query->executeQuery(); } } diff --git a/src/lib/Search/Legacy/Content/Common/Gateway/CriterionHandler/FullText.php b/src/lib/Search/Legacy/Content/Common/Gateway/CriterionHandler/FullText.php index ceef761d1c..28a2acba79 100644 --- a/src/lib/Search/Legacy/Content/Common/Gateway/CriterionHandler/FullText.php +++ b/src/lib/Search/Legacy/Content/Common/Gateway/CriterionHandler/FullText.php @@ -271,7 +271,7 @@ protected function getStopWordThresholdValue(): int ->select($this->dbPlatform->getCountExpression('id')) ->from(ContentGateway::CONTENT_ITEM_TABLE); - $count = (int)$query->execute()->fetchOne(); + $count = (int)$query->executeQuery()->fetchOne(); // Calculate the int stopWordThresholdValue based on count (first column) * factor return $this->stopWordThresholdValue = (int)($count * $this->configuration['stopWordThresholdFactor']); diff --git a/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php b/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php index 297795b865..a7759727a4 100644 --- a/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php @@ -189,7 +189,7 @@ private function getResultCount(CriterionInterface $filter, array $languageFilte $this->getQueryCondition($filter, $query, $languageFilter) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchOne(); } @@ -255,7 +255,7 @@ private function getContentInfoList( $query->setMaxResults($limit); $query->setFirstResult($offset); - $statement = $query->execute(); + $statement = $query->executeQuery(); return $statement->fetchAll(FetchMode::ASSOCIATIVE); } diff --git a/src/lib/Search/Legacy/Content/IndexerGateway.php b/src/lib/Search/Legacy/Content/IndexerGateway.php index db4a5e4403..504b177026 100644 --- a/src/lib/Search/Legacy/Content/IndexerGateway.php +++ b/src/lib/Search/Legacy/Content/IndexerGateway.php @@ -35,7 +35,7 @@ public function getContentSince(DateTimeInterface $since, int $iterationCount): $query = $this->buildQueryForContentSince($since); $query->orderBy('c.modified'); - yield from $this->fetchIteration($query->execute(), $iterationCount); + yield from $this->fetchIteration($query->executeQuery(), $iterationCount); } public function countContentSince(DateTimeInterface $since): int @@ -44,14 +44,14 @@ public function countContentSince(DateTimeInterface $since): int $this->buildQueryForContentSince($since) ); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function getContentInSubtree(string $locationPath, int $iterationCount): Generator { $query = $this->buildQueryForContentInSubtree($locationPath); - yield from $this->fetchIteration($query->execute(), $iterationCount); + yield from $this->fetchIteration($query->executeQuery(), $iterationCount); } public function countContentInSubtree(string $locationPath): int @@ -60,14 +60,14 @@ public function countContentInSubtree(string $locationPath): int $this->buildQueryForContentInSubtree($locationPath) ); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } public function getAllContent(int $iterationCount): Generator { $query = $this->buildQueryForAllContent(); - yield from $this->fetchIteration($query->execute(), $iterationCount); + yield from $this->fetchIteration($query->executeQuery(), $iterationCount); } public function countAllContent(): int @@ -76,7 +76,7 @@ public function countAllContent(): int $this->buildQueryForAllContent() ); - return (int)$query->execute()->fetchOne(); + return (int)$query->executeQuery()->fetchOne(); } private function buildQueryForContentSince(DateTimeInterface $since): QueryBuilder diff --git a/src/lib/Search/Legacy/Content/Location/Gateway/DoctrineDatabase.php b/src/lib/Search/Legacy/Content/Location/Gateway/DoctrineDatabase.php index cad34405ff..3b58029014 100644 --- a/src/lib/Search/Legacy/Content/Location/Gateway/DoctrineDatabase.php +++ b/src/lib/Search/Legacy/Content/Location/Gateway/DoctrineDatabase.php @@ -155,7 +155,7 @@ public function find( $selectQuery->setMaxResults($limit); $selectQuery->setFirstResult($offset); - $statement = $selectQuery->execute(); + $statement = $selectQuery->executeQuery(); return [ 'count' => $count, @@ -224,7 +224,7 @@ private function getTotalCount(CriterionInterface $criterion, array $languageFil ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchOne(); } diff --git a/src/lib/Search/Legacy/Content/WordIndexer/Repository/SearchIndex.php b/src/lib/Search/Legacy/Content/WordIndexer/Repository/SearchIndex.php index fe0139d8f4..6c1a67fe88 100644 --- a/src/lib/Search/Legacy/Content/WordIndexer/Repository/SearchIndex.php +++ b/src/lib/Search/Legacy/Content/WordIndexer/Repository/SearchIndex.php @@ -43,7 +43,7 @@ public function getWords(array $words): array // use array_map as some DBMS-es do not cast integers to strings by default ->setParameter('words', array_map('strval', $words), Connection::PARAM_STR_ARRAY); - return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); } /** @@ -56,7 +56,7 @@ public function incrementWordObjectCount(array $wordId): void $this ->getWordUpdateQuery($wordId) ->set('object_count', 'object_count + 1') - ->execute(); + ->executeStatement(); } /** @@ -69,7 +69,7 @@ public function decrementWordObjectCount(array $wordId): void $this ->getWordUpdateQuery($wordId) ->set('object_count', 'object_count - 1') - ->execute(); + ->executeStatement(); } /** @@ -92,7 +92,7 @@ public function addWords(array $words): void foreach ($words as $word) { $query->setParameter('word', $word); - $query->execute(); + $query->executeStatement(); } } @@ -110,7 +110,7 @@ public function purge(): void $this->connection ->createQueryBuilder() ->delete($tableName) - ->execute(); + ->executeStatement(); } $this->connection->commit(); } @@ -187,7 +187,7 @@ public function addObjectWordLink( ] ); - $query->execute(); + $query->executeStatement(); } /** @@ -206,7 +206,7 @@ public function getContentObjectWords(int $contentId): array ) ); - return $query->execute()->fetchAll(FetchMode::COLUMN); + return $query->executeQuery()->fetchAll(FetchMode::COLUMN); } /** @@ -224,7 +224,7 @@ public function deleteWordsWithoutObjects(): int ) ); - return $query->execute(); + return $query->executeStatement(); } /** @@ -242,7 +242,7 @@ public function deleteObjectWordsLink(int $contentId): int ) ); - return $query->execute(); + return $query->executeStatement(); } /** diff --git a/tests/integration/Core/Repository/BaseTrashServiceTest.php b/tests/integration/Core/Repository/BaseTrashServiceTest.php index 5e68e4a76a..393439f4e5 100644 --- a/tests/integration/Core/Repository/BaseTrashServiceTest.php +++ b/tests/integration/Core/Repository/BaseTrashServiceTest.php @@ -56,6 +56,6 @@ protected function updateTrashedDate(int $locationId, int $newTimestamp): void ->where('node_id = :location_id') ->setParameter('trashed_timestamp', $newTimestamp, ParameterType::INTEGER) ->setParameter('location_id', $locationId, ParameterType::INTEGER); - $query->execute(); + $query->executeStatement(); } } diff --git a/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php b/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php index c333496114..070cdec67d 100644 --- a/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php @@ -864,7 +864,7 @@ private function fetchXML(int $contentId, int $versionNo, int $fieldDefinitionId ->setParameter('version', $versionNo, ParameterType::INTEGER) ->setParameter('contentobject_id', $contentId, ParameterType::INTEGER); - $result = $query->execute()->fetchAssociative(); + $result = $query->executeQuery()->fetchAssociative(); self::assertNotFalse($result); return $result; @@ -912,7 +912,7 @@ private function updateXML( ->setParameter('version', $versionNo, ParameterType::INTEGER) ->setParameter('contentobject_id', $contentId, ParameterType::INTEGER); - $query->execute(); + $query->executeQuery(); } /** diff --git a/tests/integration/Core/Repository/LocationServiceTest.php b/tests/integration/Core/Repository/LocationServiceTest.php index 63875e9cb3..afd41127ac 100644 --- a/tests/integration/Core/Repository/LocationServiceTest.php +++ b/tests/integration/Core/Repository/LocationServiceTest.php @@ -3399,7 +3399,7 @@ public function testMoveSubtreeUpdatesPathIdentificationString(): void self::assertEquals( 'top_node/parent/move_me', - $query->execute()->fetchColumn() + $query->executeQuery()->fetchColumn() ); } diff --git a/tests/integration/Core/Repository/URLAliasServiceTest.php b/tests/integration/Core/Repository/URLAliasServiceTest.php index 77fd6821fc..39376594d0 100644 --- a/tests/integration/Core/Repository/URLAliasServiceTest.php +++ b/tests/integration/Core/Repository/URLAliasServiceTest.php @@ -1631,20 +1631,20 @@ public function testDeleteCorruptedUrlAliases() $connection = $this->getRawDatabaseConnection(); $query = $connection->createQueryBuilder()->select('*')->from('ezurlalias_ml'); - $originalRows = $query->execute()->fetchAll(PDO::FETCH_ASSOC); + $originalRows = $query->executeStatement()->fetchAll(PDO::FETCH_ASSOC); $expectedCount = count($originalRows); $expectedCount += $this->insertBrokenUrlAliasTableFixtures($connection); // sanity check - $updatedRows = $query->execute()->fetchAll(PDO::FETCH_ASSOC); + $updatedRows = $query->executeStatement()->fetchAll(PDO::FETCH_ASSOC); self::assertCount($expectedCount, $updatedRows, 'Found unexpected number of new rows'); // BEGIN API use case $urlAliasService->deleteCorruptedUrlAliases(); // END API use case - $updatedRows = $query->execute()->fetchAll(PDO::FETCH_ASSOC); + $updatedRows = $query->executeStatement()->fetchAll(PDO::FETCH_ASSOC); self::assertCount( // API should also remove already broken pre-existing URL aliases count($originalRows) - 4, @@ -1811,7 +1811,7 @@ private function insertBrokenUrlAliasTableFixtures(Connection $connection): int $row[$columnName] = $query->createNamedParameter($value); } $query->values($row); - $query->execute(); + $query->executeStatement(); } return count($rows); diff --git a/tests/integration/Core/Repository/UserServiceTest.php b/tests/integration/Core/Repository/UserServiceTest.php index df35be828b..2a18c9b4f0 100644 --- a/tests/integration/Core/Repository/UserServiceTest.php +++ b/tests/integration/Core/Repository/UserServiceTest.php @@ -3498,7 +3498,7 @@ protected function updateRawPasswordHash(int $userId, int $newHashType): void ->setParameter('wrong_hash_type', $newHashType, ParameterType::INTEGER) ->setParameter('user_id', $userId); - $queryBuilder->execute(); + $queryBuilder->executeStatement(); } private function assertIsSameUser(User $expectedUser, User $actualUser): void diff --git a/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php b/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php index 729edf270e..0856e61211 100644 --- a/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php +++ b/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php @@ -86,7 +86,7 @@ public function testInsertUrl() ->setParameter('id', $id, \PDO::PARAM_INT) ; - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchAllAssociative(); $expected = [ @@ -130,7 +130,7 @@ public function testLinkUrl() ->setParameter('urlId', $urlId, \PDO::PARAM_INT) ; - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchAllAssociative(); @@ -161,7 +161,7 @@ public function testUnlinkUrl() $query = $this->connection->createQueryBuilder(); $query->select('*')->from('ezurl_object_link'); - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchAllAssociative(); $expected = [ @@ -178,7 +178,7 @@ public function testUnlinkUrl() $query = $this->connection->createQueryBuilder(); $query->select('*')->from('ezurl'); - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetchAllAssociative(); diff --git a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php index b019d0b74c..f5c201ac3e 100644 --- a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php @@ -1703,7 +1703,7 @@ protected function countContentRelations(?int $fromId = null, ?int $toId = null) ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchColumn(); } @@ -1736,7 +1736,7 @@ protected function countContentFields(?int $contentId = null): int ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchColumn(); } @@ -1769,7 +1769,7 @@ protected function countContentVersions(?int $contentId = null): int ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchColumn(); } @@ -1802,7 +1802,7 @@ protected function countContentNames(?int $contentId = null): int ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchColumn(); } @@ -1834,7 +1834,7 @@ protected function countContent(?int $contentId = null): int ); } - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchColumn(); } diff --git a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php index bc531c63c1..6ed0cafeff 100644 --- a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php @@ -932,7 +932,7 @@ public function testDeleteNodeAssignmentWithSecondArgument() ->where( $query->expr()->eq('contentobject_id', 11) ); - $statement = $query->execute(); + $statement = $query->executeQuery(); $nodeAssignmentsCount = (int)$statement->fetchColumn(); $gateway->deleteNodeAssignment(11, 1); @@ -1021,7 +1021,7 @@ public function testConvertNodeAssignments($field, $value) ); if ($field === 'modified_subnode') { - $statement = $query->execute(); + $statement = $query->executeQuery(); $result = $statement->fetch(FetchMode::ASSOCIATIVE); self::assertGreaterThanOrEqual($value, $result); } else { @@ -1240,7 +1240,7 @@ public function testChangeMainLocation() ), ] ); - $query->execute(); + $query->executeStatement(); $query = $connection->createQueryBuilder(); $query @@ -1264,7 +1264,7 @@ public function testChangeMainLocation() ), ] ); - $query->execute(); + $query->executeStatement(); $gateway = $this->getLocationGateway(); @@ -1392,7 +1392,7 @@ public function testGetFallbackMainNodeData(): void ), ] ); - $query->execute(); + $query->executeStatement(); $gateway = $this->getLocationGateway(); $data = $gateway->getFallbackMainNodeData(12, 13); diff --git a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php index f8f6c4b221..2e8e7da253 100644 --- a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php +++ b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php @@ -435,7 +435,7 @@ public function testCountLocationsByContentId() ), ] ); - $query->execute(); + $query->executeStatement(); self::assertSame(2, $handler->countLocationsByContentId(67)); } } diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php index 1a4bc9ddec..065fe11063 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php @@ -5335,7 +5335,7 @@ protected function countRows(): int ->select($connection->getDatabasePlatform()->getCountExpression('*')) ->from(UrlAliasGateway::TABLE); - $statement = $query->execute(); + $statement = $query->executeQuery(); return (int)$statement->fetchColumn(); } diff --git a/tests/lib/Persistence/Legacy/TestCase.php b/tests/lib/Persistence/Legacy/TestCase.php index f1427ac17b..cfc0cb200b 100644 --- a/tests/lib/Persistence/Legacy/TestCase.php +++ b/tests/lib/Persistence/Legacy/TestCase.php @@ -223,7 +223,7 @@ public static function assertQueryResult( QueryBuilder $query, string $message = '' ): void { - $result = $query->execute()->fetchAll(FetchMode::ASSOCIATIVE); + $result = $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); self::assertEquals( self::getResultTextRepresentation($expectation), diff --git a/tests/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabaseTest.php index 29ebce5b2d..c411ed0cb4 100644 --- a/tests/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/UserPreference/Gateway/DoctrineDatabaseTest.php @@ -133,7 +133,7 @@ private function loadUserPreference(int $id): array $queryBuilder->createPositionalParameter($id, ParameterType::INTEGER) ) ); - $result = $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE); + $result = $queryBuilder->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); return reset($result); } From 3eb332c05a237e57e92ed5a837ff6210fc062b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 19:05:58 +0200 Subject: [PATCH 09/26] fixup! [doctrine/dbal] Fixed usage of deprecated \Doctrine\DBAL\Query\QueryBuilder::execute method --- .../Legacy/Content/Location/Gateway/DoctrineDatabase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php index 6b8a02c378..1a3b7e2538 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php @@ -937,7 +937,7 @@ public function createLocationsFromNodeAssignments(int $contentId, int $versionN ) ) ->orderBy('id'); - $statement = $query->executeStatement(); + $statement = $query->executeQuery(); // convert all these assignments to nodes From 353ddc0424e8a0eca144e3cb77aa7290beab3001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 19:06:30 +0200 Subject: [PATCH 10/26] [doctrine/dbal] Replaced usage of deprecated fetchColumn method with fetchOne (tests) --- .../Core/Repository/LocationServiceTest.php | 2 +- .../Legacy/Content/Gateway/DoctrineDatabaseTest.php | 10 +++++----- .../Content/Location/Gateway/DoctrineDatabaseTest.php | 2 +- .../Legacy/Content/UrlAlias/UrlAliasHandlerTest.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration/Core/Repository/LocationServiceTest.php b/tests/integration/Core/Repository/LocationServiceTest.php index afd41127ac..45d8c49f85 100644 --- a/tests/integration/Core/Repository/LocationServiceTest.php +++ b/tests/integration/Core/Repository/LocationServiceTest.php @@ -3399,7 +3399,7 @@ public function testMoveSubtreeUpdatesPathIdentificationString(): void self::assertEquals( 'top_node/parent/move_me', - $query->executeQuery()->fetchColumn() + $query->executeQuery()->fetchOne() ); } diff --git a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php index f5c201ac3e..5830288b55 100644 --- a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php @@ -1705,7 +1705,7 @@ protected function countContentRelations(?int $fromId = null, ?int $toId = null) $statement = $query->executeQuery(); - return (int)$statement->fetchColumn(); + return (int)$statement->fetchOne(); } /** @@ -1738,7 +1738,7 @@ protected function countContentFields(?int $contentId = null): int $statement = $query->executeQuery(); - return (int)$statement->fetchColumn(); + return (int)$statement->fetchOne(); } /** @@ -1771,7 +1771,7 @@ protected function countContentVersions(?int $contentId = null): int $statement = $query->executeQuery(); - return (int)$statement->fetchColumn(); + return (int)$statement->fetchOne(); } /** @@ -1804,7 +1804,7 @@ protected function countContentNames(?int $contentId = null): int $statement = $query->executeQuery(); - return (int)$statement->fetchColumn(); + return (int)$statement->fetchOne(); } /** @@ -1836,7 +1836,7 @@ protected function countContent(?int $contentId = null): int $statement = $query->executeQuery(); - return (int)$statement->fetchColumn(); + return (int)$statement->fetchOne(); } /** diff --git a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php index 6ed0cafeff..c49a21e8b1 100644 --- a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php @@ -933,7 +933,7 @@ public function testDeleteNodeAssignmentWithSecondArgument() $query->expr()->eq('contentobject_id', 11) ); $statement = $query->executeQuery(); - $nodeAssignmentsCount = (int)$statement->fetchColumn(); + $nodeAssignmentsCount = (int)$statement->fetchOne(); $gateway->deleteNodeAssignment(11, 1); diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php index 065fe11063..838ee5e9f9 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/UrlAliasHandlerTest.php @@ -5337,7 +5337,7 @@ protected function countRows(): int $statement = $query->executeQuery(); - return (int)$statement->fetchColumn(); + return (int)$statement->fetchOne(); } /** @var \Ibexa\Core\Persistence\Legacy\Content\Location\Gateway */ From afc0fde19b0becfd3cbc880926386da3da639563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 20:27:19 +0200 Subject: [PATCH 11/26] IBX-8471: Upgraded SiteAccess Matcher serializers to Symfony 7 --- .../AbstractPropertyWhitelistNormalizer.php | 41 ----- .../Serializer/CompoundMatcherNormalizer.php | 78 +++++++--- .../Serializer/HostElementNormalizer.php | 49 +++++- .../Serializer/HostTextNormalizer.php | 47 +++++- .../Component/Serializer/MapNormalizer.php | 58 ++++++- .../Serializer/MatcherDenormalizer.php | 9 +- .../Component/Serializer/RegexNormalizer.php | 52 ++++++- .../SimplifiedRequestNormalizer.php | 55 +++++-- .../Serializer/SiteAccessNormalizer.php | 41 +++-- .../Serializer/URIElementNormalizer.php | 49 +++++- .../Serializer/URITextNormalizer.php | 47 +++++- .../Matcher/AffixBasedTextMatcher.php | 8 + .../Symfony/SiteAccess/Matcher/Compound.php | 55 ++++--- .../Matcher/Compound/LogicalAnd.php | 12 +- .../SiteAccess/Matcher/Compound/LogicalOr.php | 10 +- .../SiteAccess/Matcher/CompoundInterface.php | 9 +- .../SiteAccess/Matcher/HostElement.php | 77 +++++++--- .../Symfony/SiteAccess/Matcher/HostText.php | 4 +- .../MVC/Symfony/SiteAccess/Matcher/Map.php | 65 +++----- .../Symfony/SiteAccess/Matcher/Map/Host.php | 7 +- .../Symfony/SiteAccess/Matcher/Map/Port.php | 36 +++-- .../Symfony/SiteAccess/Matcher/Map/URI.php | 9 +- .../MVC/Symfony/SiteAccess/Matcher/Regex.php | 50 +++--- .../Symfony/SiteAccess/Matcher/URIElement.php | 93 +++++++----- .../Symfony/SiteAccess/Matcher/URIText.php | 4 +- .../Symfony/SiteAccess/VersatileMatcher.php | 16 +- .../CompoundMatcherNormalizerTest.php | 142 +++++++++++++----- .../Serializer/HostElementNormalizerTest.php | 34 ++++- .../Serializer/MapNormalizerTest.php | 1 + .../Serializer/RegexNormalizerTest.php | 2 +- .../SimplifiedRequestNormalizerTest.php | 7 +- .../Serializer/Stubs/CompoundStub.php | 16 +- .../Serializer/Stubs/MatcherStub.php | 22 ++- .../Serializer/Stubs/RegexMatcher.php | 5 +- .../Serializer/Stubs/SerializerStub.php | 56 ------- .../Serializer/URIElementNormalizerTest.php | 8 +- .../Serializer/URITextNormalizerTest.php | 6 + .../SiteAccess/Compound/CompoundAndTest.php | 29 ++-- .../SiteAccess/Compound/CompoundOrTest.php | 22 +-- .../SiteAccess/MatcherSerializationTest.php | 69 ++++----- .../SiteAccess/RouterHostPortURITest.php | 2 +- 41 files changed, 889 insertions(+), 513 deletions(-) delete mode 100644 src/lib/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php delete mode 100644 tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php diff --git a/src/lib/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php deleted file mode 100644 index 8f89e3128e..0000000000 --- a/src/lib/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface - */ - public function normalize($object, string $format = null, array $context = []): array - { - $data = parent::normalize($object, $format, $context) ?? []; - if (!is_array($data)) { - throw new LogicException(sprintf('Expected an array, got "%s"', gettype($data))); - } - - foreach (array_keys(iterator_to_array($data)) as $property) { - if (!in_array($property, $this->getAllowedProperties(), true)) { - unset($data[$property]); - } - } - - return $data; - } - - /** - * @return string[] - */ - abstract protected function getAllowedProperties(): array; -} diff --git a/src/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php index 157f7cdd00..df0716972a 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php @@ -4,48 +4,63 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Core\MVC\Symfony\Component\Serializer; -use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; +use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound; +use Symfony\Component\Serializer\Exception\LogicException; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -class CompoundMatcherNormalizer extends AbstractPropertyWhitelistNormalizer implements DenormalizerAwareInterface +/** + * @internal + * + * @phpstan-type TNormalizedCompoundMatcherData array{type: class-string, subMatchers: array, config: array, matchersMap: array} + */ +class CompoundMatcherNormalizer implements NormalizerInterface, NormalizerAwareInterface, DenormalizerInterface, DenormalizerAwareInterface { use DenormalizerAwareTrait; + use NormalizerAwareTrait; /** - * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound $object + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound $data + * + * @phpstan-return TNormalizedCompoundMatcherData $data * * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface * * @see \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound::__sleep */ - public function normalize($object, string $format = null, array $context = []): array + public function normalize(mixed $data, string $format = null, array $context = []): array { - $data = parent::normalize($object, $format, $context); - - /** @var array $data */ - $data['config'] = []; - $data['matchersMap'] = []; + /** @var array> $subMatchers */ + $subMatchers = $this->normalizer->normalize($data->getSubMatchers(), $format, $context); - return $data; + return [ + 'type' => $data::class, + 'subMatchers' => $subMatchers, + 'config' => [], + 'matchersMap' => [], + ]; } - protected function getAllowedProperties(): array + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { - return ['subMatchers']; + return $data instanceof Compound; } - public function supportsNormalization($data, string $format = null): bool - { - return $data instanceof Matcher\Compound; - } - - public function supportsDenormalization($data, string $type, string $format = null): bool - { - return is_a($type, Matcher\Compound::class, true); + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return is_a($type, Compound::class, true) && is_a($data['type'] ?? null, Compound::class, true); } /** @@ -53,15 +68,20 @@ public function supportsDenormalization($data, string $type, string $format = nu * * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface */ - public function denormalize($data, string $type, ?string $format = null, array $context = []): object + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): object { - $compoundMatcher = new $type([]); + $compoundMatcherType = $data['type'] ?? throw new LogicException('Unknown compound matcher type'); + if (!is_a($compoundMatcherType, Compound::class, true)) { + throw new LogicException(sprintf('%s is not a subtype of %s', $compoundMatcherType, Compound::class)); + } + + $compoundMatcher = new $compoundMatcherType($data['config'] ?? []); $subMatchers = []; - foreach ($context['serialized_siteaccess_sub_matchers'] ?? [] as $matcherType => $subMatcher) { - $subMatchers[$matcherType] = $this->serializer->deserialize( + foreach ($data['subMatchers'] ?? [] as $matcherType => $subMatcher) { + $subMatchers[$matcherType] = $this->denormalizer->denormalize( $subMatcher, $matcherType, - $format ?? 'json', + $format, $context ); } @@ -69,4 +89,12 @@ public function denormalize($data, string $type, ?string $format = null, array $ return $compoundMatcher; } + + public function getSupportedTypes(?string $format): array + { + return [ + // don't cache it, as the normalizer relies on other things besides type + Compound::class => false, + ]; + } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/HostElementNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/HostElementNormalizer.php index 3ba19e438f..1c243726be 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/HostElementNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/HostElementNormalizer.php @@ -9,19 +9,58 @@ namespace Ibexa\Core\MVC\Symfony\Component\Serializer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\HostElement; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class HostElementNormalizer extends AbstractPropertyWhitelistNormalizer +/** + * @internal + */ +final class HostElementNormalizer implements NormalizerInterface, DenormalizerInterface { - public function supportsNormalization($data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof HostElement; } /** - * @see \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\HostElement::__sleep + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\HostElement $data + * + * @return array{elementNumber: int, hostElements: array} */ - protected function getAllowedProperties(): array + public function normalize( + mixed $data, + ?string $format = null, + array $context = [] + ): array { + return [ + 'elementNumber' => $data->getElementNumber(), + 'hostElements' => $data->getHostElements(), + ]; + } + + public function getSupportedTypes(?string $format): array + { + return [ + HostElement::class => true, + ]; + } + + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): HostElement { - return ['elementNumber', 'hostElements']; + $hostElement = new HostElement($data['elementNumber']); + if (!empty($data['hostElements'])) { + $hostElement->setHostElements($data['hostElements']); + } + + return $hostElement; + } + + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return $type === HostElement::class; } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/HostTextNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/HostTextNormalizer.php index af7b1a6693..527fb73ce5 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/HostTextNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/HostTextNormalizer.php @@ -9,16 +9,53 @@ namespace Ibexa\Core\MVC\Symfony\Component\Serializer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\HostText; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class HostTextNormalizer extends AbstractPropertyWhitelistNormalizer +/** + * @internal + */ +final class HostTextNormalizer implements NormalizerInterface, DenormalizerInterface { - protected function getAllowedProperties(): array - { - return ['siteAccessesConfiguration']; + /** + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\HostText $data + * @param array $context + * + * @phpstan-return array{siteAccessesConfiguration: array{prefix?: string, suffix?: string}} + */ + public function normalize( + mixed $data, + ?string $format = null, + array $context = [] + ): array { + return [ + 'siteAccessesConfiguration' => $data->getSiteAccessesConfiguration(), + ]; } - public function supportsNormalization($data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof HostText; } + + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed + { + return new HostText($data['siteAccessesConfiguration'] ?? []); + } + + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return $type === HostText::class; + } + + public function getSupportedTypes(?string $format): array + { + return [ + HostText::class => true, + ]; + } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/MapNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/MapNormalizer.php index 80b60cb5bf..72b25c2b7d 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/MapNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/MapNormalizer.php @@ -9,28 +9,70 @@ namespace Ibexa\Core\MVC\Symfony\Component\Serializer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map; -use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; +use Symfony\Component\Serializer\Exception\LogicException; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class MapNormalizer extends PropertyNormalizer +/** + * @internal + */ +final class MapNormalizer implements NormalizerInterface, DenormalizerInterface { /** - * @see \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map::__sleep + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map $data * - * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map $object + * @return array{ + * type: class-string<\Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map>, + * key: string|null, + * map: array{}, + * reverseMap: array{} + * } * - * @return array{key: string, map: array{}, reverseMap: array{}} + * @see \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map::__sleep */ - public function normalize($object, string $format = null, array $context = []): array + public function normalize(mixed $data, ?string $format = null, array $context = []): array { return [ - 'key' => $object->getMapKey(), + 'type' => $data::class, + 'key' => $data->getMapKey(), 'map' => [], 'reverseMap' => [], ]; } - public function supportsNormalization($data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof Map; } + + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): Map + { + $mapMatcherType = $data['type'] ?? throw new LogicException('Unknown Map matcher type'); + if (!is_a($mapMatcherType, Map::class, true)) { + throw new LogicException(sprintf('%s is not a subtype of %s', $mapMatcherType, Map::class)); + } + + $mapMatcher = new $mapMatcherType($data['map'] ?? []); + if (isset($data['key'])) { + $mapMatcher->setMapKey($data['key']); + } + + return $mapMatcher; + } + + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return is_a($type, Map::class, true) && is_a($data['type'] ?? null, Map::class, true); + } + + public function getSupportedTypes(?string $format): array + { + return [ + Map::class => true, + ]; + } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/MatcherDenormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/MatcherDenormalizer.php index f34b4c0c87..95f0a77d5a 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/MatcherDenormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/MatcherDenormalizer.php @@ -20,7 +20,7 @@ */ final class MatcherDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface { - private const MATCHER_NORMALIZER_ALREADY_WORKED = self::class . '_ALREADY_CALLED'; + private const string MATCHER_NORMALIZER_ALREADY_WORKED = self::class . '_ALREADY_CALLED'; use DenormalizerAwareTrait; @@ -56,4 +56,11 @@ public function supportsDenormalization($data, string $type, ?string $format = n return is_subclass_of($type, Matcher::class) && $this->registry->hasMatcher($type); } + + public function getSupportedTypes(?string $format): array + { + return [ + Matcher::class => false, + ]; + } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/RegexNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/RegexNormalizer.php index c605c30281..d30f098e5e 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/RegexNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/RegexNormalizer.php @@ -9,19 +9,61 @@ namespace Ibexa\Core\MVC\Symfony\Component\Serializer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Regex; +use Symfony\Component\Serializer\Exception\LogicException; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class RegexNormalizer extends AbstractPropertyWhitelistNormalizer +/** + * @internal + */ +final class RegexNormalizer implements NormalizerInterface, DenormalizerInterface { - public function supportsNormalization($data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof Regex; } /** - * @see \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Regex::__sleep + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Regex $data + * + * @return array{type: class-string, regex: string, itemNumber: int} */ - protected function getAllowedProperties(): array + public function normalize(mixed $data, ?string $format = null, array $context = []): array + { + return [ + 'type' => $data::class, + 'regex' => $data->getRegex(), + 'itemNumber' => $data->getItemNumber(), + ]; + } + + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): Regex + { + $mapMatcherType = $data['type'] ?? throw new LogicException('Unknown Regex matcher type'); + if (!is_a($mapMatcherType, Regex::class, true)) { + throw new LogicException(sprintf('%s is not a subtype of %s', $mapMatcherType, Regex::class)); + } + + $regexMatcher = $data['type']($data['regex'], $data['itemNumber']); + assert($regexMatcher instanceof Regex); + + return $regexMatcher; + } + + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return is_a($type, Regex::class, true) && is_a($data['type'] ?? null, Regex::class, true); + } + + public function getSupportedTypes(?string $format): array { - return ['regex', 'itemNumber', 'matchedSiteAccess']; + return [ + // false: building specific instance of Regex class depends on its data, not a static type + Regex::class => false, + ]; } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizer.php index 1251e143f0..b7c3e6268a 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizer.php @@ -8,18 +8,22 @@ namespace Ibexa\Core\MVC\Symfony\Component\Serializer; use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; -use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class SimplifiedRequestNormalizer extends PropertyNormalizer +/** + * @internal + */ +final class SimplifiedRequestNormalizer implements NormalizerInterface, DenormalizerInterface { /** - * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $object + * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $data * * @return array{ * scheme: ?string, * host: ?string, * port: ?int, - * pathinfo: ?string, + * pathInfo: ?string, * queryParams: ?array, * languages: ?string[], * headers: ?array{} @@ -27,15 +31,15 @@ final class SimplifiedRequestNormalizer extends PropertyNormalizer * * @see \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize */ - public function normalize($object, $format = null, array $context = []): array + public function normalize(mixed $data, ?string $format = null, array $context = []): array { return [ - 'scheme' => $object->getScheme(), - 'host' => $object->getHost(), - 'port' => $object->getPort(), - 'pathinfo' => $object->getPathInfo(), - 'queryParams' => $object->getQueryParams(), - 'languages' => $object->getLanguages(), + 'scheme' => $data->getScheme(), + 'host' => $data->getHost(), + 'port' => $data->getPort(), + 'pathInfo' => $data->getPathInfo(), + 'queryParams' => $data->getQueryParams(), + 'languages' => $data->getLanguages(), 'headers' => [], ]; } @@ -44,4 +48,33 @@ public function supportsNormalization($data, $format = null, array $context = [] { return $data instanceof SimplifiedRequest; } + + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed + { + return new SimplifiedRequest( + $data['scheme'] ?? null, + $data['host'] ?? null, + $data['port'] ?? null, + $data['pathInfo'] ?? null, + $data['queryParams'] ?? null, + $data['languages'] ?? null, + $data['headers'] ?? [], + ); + } + + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return $type === SimplifiedRequest::class; + } + + public function getSupportedTypes(?string $format): array + { + return [ + SimplifiedRequest::class => true, + ]; + } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/SiteAccessNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/SiteAccessNormalizer.php index a6a95082e8..f755b7d9b6 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/SiteAccessNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/SiteAccessNormalizer.php @@ -25,7 +25,7 @@ final class SiteAccessNormalizer implements DenormalizerInterface, DenormalizerA use DenormalizerAwareTrait; use SerializerAwareTrait; - public function denormalize($data, string $type, ?string $format = null, array $context = []): object + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): object { // BC for SiteAccess being serialized/normalized using json_encode via \Ibexa\Bundle\Core\Fragment\SiteAccessSerializer $matcherType = $data['matcher']['type'] ?? $data['matcher']; @@ -35,7 +35,7 @@ public function denormalize($data, string $type, ?string $format = null, array $ $data['name'], $data['matchingType'], $data['matcher'] !== null - ? $this->serializer->deserialize( + ? $this->serializer?->deserialize( $matcherData, $matcherType, $format ?? 'json', @@ -50,37 +50,50 @@ public function denormalize($data, string $type, ?string $format = null, array $ /** * @phpstan-param array $context */ - public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool { return $type === SiteAccess::class; } - public function supportsNormalization($data, ?string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof SiteAccess; } /** - * @param \Ibexa\Core\MVC\Symfony\SiteAccess $object + * @param \Ibexa\Core\MVC\Symfony\SiteAccess $data * - * @return array{name: string, matchingType: string, matcher: array{type: class-string, data: string}|null, provider: string|null, groups: array} + * @return array{ + * name: string, + * matchingType: string, + * matcher: array{type: class-string<\Ibexa\Core\MVC\Symfony\SiteAccess\Matcher>, data: string|null}|null, + * provider: string|null, + * groups: array<\Ibexa\Core\MVC\Symfony\SiteAccessGroup> + * } */ - public function normalize($object, ?string $format = null, array $context = []): array + public function normalize(mixed $data, ?string $format = null, array $context = []): array { $matcherData = null; - if (is_object($object->matcher)) { + if (is_object($data->matcher)) { $matcherData = [ - 'type' => get_class($object->matcher), - 'data' => $this->serializer->serialize($object->matcher, $format ?? 'json', $context), + 'type' => get_class($data->matcher), + 'data' => $this->serializer?->serialize($data->matcher, $format ?? 'json', $context), ]; } return [ - 'name' => $object->name, - 'matchingType' => $object->matchingType, + 'name' => $data->name, + 'matchingType' => $data->matchingType, 'matcher' => $matcherData, - 'provider' => $object->provider, - 'groups' => $object->groups, + 'provider' => $data->provider, + 'groups' => $data->groups, + ]; + } + + public function getSupportedTypes(?string $format): array + { + return [ + SiteAccess::class => true, ]; } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/URIElementNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/URIElementNormalizer.php index 0ac40bceec..d9f2f9dc0a 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/URIElementNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/URIElementNormalizer.php @@ -9,19 +9,58 @@ namespace Ibexa\Core\MVC\Symfony\Component\Serializer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIElement; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class URIElementNormalizer extends AbstractPropertyWhitelistNormalizer +/** + * @internal + */ +final class URIElementNormalizer implements NormalizerInterface, DenormalizerInterface { - public function supportsNormalization($data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof URIElement; } /** - * @see \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIElement::__sleep + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIElement $data + * + * @return array{elementNumber: int, uriElements: array} */ - protected function getAllowedProperties(): array + public function normalize( + mixed $data, + ?string $format = null, + array $context = [] + ): array { + return [ + 'elementNumber' => $data->getElementNumber(), + 'uriElements' => $data->getUriElements(), + ]; + } + + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): URIElement + { + $uriElement = new URIElement($data['elementNumber']); + if (!empty($data['uriElements'])) { + $uriElement->setUriElements($data['uriElements']); + } + + return $uriElement; + } + + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return $type === URIElement::class; + } + + public function getSupportedTypes(?string $format): array { - return ['elementNumber', 'uriElements']; + return [ + URIElement::class => true, + ]; } } diff --git a/src/lib/MVC/Symfony/Component/Serializer/URITextNormalizer.php b/src/lib/MVC/Symfony/Component/Serializer/URITextNormalizer.php index a6d50a16d6..564c5cade3 100644 --- a/src/lib/MVC/Symfony/Component/Serializer/URITextNormalizer.php +++ b/src/lib/MVC/Symfony/Component/Serializer/URITextNormalizer.php @@ -9,16 +9,53 @@ namespace Ibexa\Core\MVC\Symfony\Component\Serializer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIText; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class URITextNormalizer extends AbstractPropertyWhitelistNormalizer +/** + * @internal + */ +final class URITextNormalizer implements NormalizerInterface, DenormalizerInterface { - protected function getAllowedProperties(): array - { - return ['siteAccessesConfiguration']; + /** + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIText $data + * @param array $context + * + * @phpstan-return array{siteAccessesConfiguration: array{prefix?: string, suffix?: string}} + */ + public function normalize( + mixed $data, + ?string $format = null, + array $context = [] + ): array { + return [ + 'siteAccessesConfiguration' => $data->getSiteAccessesConfiguration(), + ]; } - public function supportsNormalization($data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof URIText; } + + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed + { + return new URIText($data['siteAccessesConfiguration'] ?? []); + } + + public function supportsDenormalization( + mixed $data, + string $type, + ?string $format = null, + array $context = [] + ): bool { + return $type === URIText::class; + } + + public function getSupportedTypes(?string $format): array + { + return [ + URIText::class => true, + ]; + } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/AffixBasedTextMatcher.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/AffixBasedTextMatcher.php index 76dc56296e..298b54f220 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/AffixBasedTextMatcher.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/AffixBasedTextMatcher.php @@ -35,4 +35,12 @@ public function __construct(private readonly array $siteAccessesConfiguration) parent::__construct($this->buildRegex(), $this->getMatchedItemNumber()); } + + /** + * @phpstan-return TSiteAccessConfigurationArray + */ + public function getSiteAccessesConfiguration(): array + { + return $this->siteAccessesConfiguration; + } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound.php index b43d6bd2cc..6040f7744e 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound.php @@ -8,43 +8,52 @@ namespace Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; -use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilderInterface; use Ibexa\Core\MVC\Symfony\SiteAccess\URILexer; /** - * Base for Compound siteaccess matchers. + * Base for Compound SiteAccess matchers. * All classes extending this one must implement a NAME class constant. + * + * @phpstan-type TMatcherName class-string<\Ibexa\Core\MVC\Symfony\SiteAccess\Matcher> | literal-string + * @phpstan-type TCompoundMatcherConfig array>, match: string}> */ abstract class Compound implements CompoundInterface, URILexer { - /** @var array Collection of rules using the Compound matcher. */ - protected $config; + public const string NAME = 'compound'; /** - * Matchers map. - * Consists of an array of matchers, grouped by ruleset (so array of array of matchers). + * Collection of rules using the Compound matcher. * - * @var array + * @phpstan-var TCompoundMatcherConfig */ - protected $matchersMap = []; + protected array $config; + + /** + * Matchers' map. + * Consists of an array of matchers, grouped by ruleset (so an array of an array of matchers). + * + * @phpstan-var array | literal-string, \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher>> + */ + protected array $matchersMap; /** @var \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher[] */ - protected $subMatchers = []; + protected array $subMatchers = []; - /** @var \Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilderInterface */ - protected $matcherBuilder; + protected MatcherBuilderInterface $matcherBuilder; - /** @var \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest */ - protected $request; + protected SimplifiedRequest $request; + /** + * @phpstan-param TCompoundMatcherConfig $config + */ public function __construct(array $config) { $this->config = $config; $this->matchersMap = []; } - public function setMatcherBuilder(MatcherBuilderInterface $matcherBuilder) + public function setMatcherBuilder(MatcherBuilderInterface $matcherBuilder): void { $this->matcherBuilder = $matcherBuilder; foreach ($this->config as $i => $rule) { @@ -54,7 +63,7 @@ public function setMatcherBuilder(MatcherBuilderInterface $matcherBuilder) } } - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { $this->request = $request; foreach ($this->matchersMap as $ruleset) { @@ -64,7 +73,7 @@ public function setRequest(SimplifiedRequest $request) } } - public function getRequest() + public function getRequest(): SimplifiedRequest { return $this->request; } @@ -91,12 +100,12 @@ public function analyseLink($linkUri) return $linkUri; } - public function getSubMatchers() + public function getSubMatchers(): array { return $this->subMatchers; } - public function setSubMatchers(array $subMatchers) + public function setSubMatchers(array $subMatchers): void { $this->subMatchers = $subMatchers; } @@ -104,10 +113,8 @@ public function setSubMatchers(array $subMatchers) /** * Returns the matcher's name. * This information will be stored in the SiteAccess object itself to quickly be able to identify the matcher type. - * - * @return string */ - public function getName() + public function getName(): string { return 'compound:' . @@ -119,12 +126,12 @@ public function getName() } /** - * Serialization occurs when serializing the siteaccess for subrequests. + * Serialization occurs when serializing the SiteAccess for subrequests. */ public function __sleep() { - // We don't need the whole matcher map and the matcher builder once serialized. - // config property is not needed either as it's only needed for matching. + // we don't need the whole matcher map and the matcher builder once serialized. + // config property is not needed either as it's only necessary for matching. return ['subMatchers']; } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalAnd.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalAnd.php index 7d8c895ef6..98fa7425c8 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalAnd.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalAnd.php @@ -11,13 +11,13 @@ use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; /** - * Siteaccess matcher that allows a combination of matchers, with a logical AND. + * SiteAccess matcher that allows a combination of matchers, with a logical AND. */ -class LogicalAnd extends Compound implements VersatileMatcher +class LogicalAnd extends Compound { - public const NAME = 'logicalAnd'; + public const string NAME = 'logicalAnd'; - public function match() + public function match(): string|bool { foreach ($this->config as $i => $rule) { foreach ($rule['matchers'] as $subMatcherClass => $matchingConfig) { @@ -35,7 +35,7 @@ public function match() return false; } - public function reverseMatch($siteAccessName) + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { foreach ($this->config as $i => $rule) { if ($rule['match'] === $siteAccessName) { @@ -58,5 +58,7 @@ public function reverseMatch($siteAccessName) return $this; } } + + return null; } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalOr.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalOr.php index b7ed76ccdd..f9a36e74b7 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalOr.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Compound/LogicalOr.php @@ -11,13 +11,13 @@ use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; /** - * Siteaccess matcher that allows a combination of matchers, with a logical OR. + * SiteAccess matcher that allows a combination of matchers, with a logical OR. */ class LogicalOr extends Compound { - public const NAME = 'logicalOr'; + public const string NAME = 'logicalOr'; - public function match() + public function match(): false|string { foreach ($this->config as $i => $rule) { foreach ($rule['matchers'] as $subMatcherClass => $matchingConfig) { @@ -32,7 +32,7 @@ public function match() return false; } - public function reverseMatch($siteAccessName) + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { foreach ($this->config as $i => $rule) { if ($rule['match'] === $siteAccessName) { @@ -52,5 +52,7 @@ public function reverseMatch($siteAccessName) } } } + + return null; } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/CompoundInterface.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/CompoundInterface.php index e7615e04a4..59b2639beb 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/CompoundInterface.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/CompoundInterface.php @@ -7,30 +7,29 @@ namespace Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; -use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilderInterface; use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; interface CompoundInterface extends VersatileMatcher { /** - * Injects the matcher builder, to allow the Compound matcher to properly build the underlying matchers. + * Injects the matcher builder to allow the Compound matcher to properly build the underlying matchers. * * @param \Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilderInterface $matcherBuilder */ - public function setMatcherBuilder(MatcherBuilderInterface $matcherBuilder); + public function setMatcherBuilder(MatcherBuilderInterface $matcherBuilder): void; /** * Returns all used sub-matchers. * * @return \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher[] */ - public function getSubMatchers(); + public function getSubMatchers(): array; /** * Replaces sub-matchers. * * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher[] $subMatchers */ - public function setSubMatchers(array $subMatchers); + public function setSubMatchers(array $subMatchers): void; } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php index dba77ecc6e..b9605822c7 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php @@ -7,38 +7,34 @@ namespace Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; +use Ibexa\Core\Base\Exceptions\BadStateException; use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; class HostElement implements VersatileMatcher { - /** @var \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest */ - private $request; + private ?SimplifiedRequest $request = null; /** * Number of elements to take into account. - * - * @var int */ - private $elementNumber; + private int $elementNumber; /** * Host elements used for matching as an array. * - * @var array + * @phpstan-var list */ - private $hostElements; + private array $hostElements; /** - * Constructor. - * - * @param array|int $elementNumber Number of elements to take into account. + * @param array|int $elementNumber Number of elements to take into account. */ - public function __construct($elementNumber) + public function __construct(array|int $elementNumber) { if (is_array($elementNumber)) { // DI config parser will create an array with 'value' => number - $elementNumber = current($elementNumber); + $elementNumber = (int)current($elementNumber); } $this->elementNumber = (int)$elementNumber; @@ -50,15 +46,15 @@ public function __sleep() } /** - * Returns matching Siteaccess. + * Returns matching SiteAccess. * - * @return string|false Siteaccess matched or false. + * @return string|false SiteAccess matched or false. */ - public function match() + public function match(): string|bool { $elements = $this->getHostElements(); - return isset($elements[$this->elementNumber - 1]) ? $elements[$this->elementNumber - 1] : false; + return $elements[$this->elementNumber - 1] ?? false; } public function getName(): string @@ -71,43 +67,74 @@ public function getName(): string * * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request */ - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { $this->request = $request; } - public function getRequest() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the request is not set + */ + public function getRequest(): SimplifiedRequest { + if (null === $this->request) { + throw new BadStateException( + 'request', + sprintf( + 'Missing required request context in %s matcher', + __CLASS__ + ) + ); + } + return $this->request; } - public function reverseMatch($siteAccessName) + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException + */ + public function reverseMatch($siteAccessName): ?VersatileMatcher { - $hostElements = explode('.', (string)$this->request->getHost()); + $hostElements = explode('.', (string)$this->request?->getHost()); $elementNumber = $this->elementNumber - 1; if (!isset($hostElements[$elementNumber])) { return null; } $hostElements[$elementNumber] = $siteAccessName; - $this->request->setHost(implode('.', $hostElements)); + $this->getRequest()->setHost(implode('.', $hostElements)); return $this; } /** - * @return array + * @phpstan-param list $hostElements + */ + public function setHostElements(array $hostElements): void + { + $this->hostElements = $hostElements; + } + + /** + * @phpstan-return list */ - private function getHostElements() + public function getHostElements(): array { if (isset($this->hostElements)) { return $this->hostElements; - } elseif (!isset($this->request)) { + } + + if (!isset($this->request)) { return []; } - $elements = explode('.', $this->request->getHost()); + $elements = explode('.', $this->request->getHost() ?? ''); return $this->hostElements = $elements; } + + public function getElementNumber(): int + { + return $this->elementNumber; + } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/HostText.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/HostText.php index d169a9801e..55f2a70c5b 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/HostText.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/HostText.php @@ -29,14 +29,14 @@ public function getName(): string public function setRequest(SimplifiedRequest $request): void { - if (!$this->element) { + if (!isset($this->element)) { $this->setMatchElement((string)$request->getHost()); } parent::setRequest($request); } - public function reverseMatch($siteAccessName): ?VersatileMatcher + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { $this->request->setHost($this->prefix . $siteAccessName . $this->suffix); diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map.php index 6b30b4253d..6e446a72e1 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map.php @@ -14,32 +14,27 @@ abstract class Map implements VersatileMatcher { /** * String that will be looked up in the map. - * - * @var string */ - protected $key; + protected ?string $key = null; /** * Map used for the matching. * - * @var array + * @var array */ - protected $map = []; + protected array $map = []; /** * Map used for reverse matching. * - * @var array + * @var array */ - protected $reverseMap = []; + protected array $reverseMap = []; - /** @var \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest */ - protected $request; + protected SimplifiedRequest $request; /** - * Constructor. - * - * @param array $map Map used for matching. + * @param array $map Map used for matching. */ public function __construct(array $map) { @@ -47,66 +42,48 @@ public function __construct(array $map) } /** - * Do not serialize the Siteaccess configuration in order to reduce ESI request URL size. + * Do not serialize the SiteAccess configuration to reduce ESI request URL size. * * @see https://issues.ibexa.co/browse/EZP-23168 * - * @return array + * @return array */ public function __sleep() { - $this->map = []; - $this->reverseMap = []; + unset($this->map, $this->reverseMap); return ['map', 'reverseMap', 'key']; } - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { $this->request = $request; } - public function getRequest() + public function getRequest(): SimplifiedRequest { return $this->request; } /** * Injects the key that will be used for matching against the map configuration. - * - * @param string $key */ - public function setMapKey($key) + public function setMapKey(?string $key): void { $this->key = $key; } - /** - * @return string - */ - public function getMapKey() + public function getMapKey(): ?string { return $this->key; } - /** - * Returns matching Siteaccess. - * - * @return string|false Siteaccess matched or false. - */ - public function match() + public function match(): string|bool { - return isset($this->map[$this->key]) - ? $this->map[$this->key] - : false; + return $this->map[$this->key] ?? false; } - /** - * @param string $siteAccessName - * - * @return \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher|Map|null - */ - public function reverseMatch($siteAccessName) + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { $reverseMap = $this->getReverseMap($siteAccessName); @@ -119,12 +96,16 @@ public function reverseMatch($siteAccessName) return $this; } - private function getReverseMap($defaultSiteAccess) + /** + * @return array + */ + private function getReverseMap(string $defaultSiteAccess): array { if (!empty($this->reverseMap)) { return $this->reverseMap; } + /** @var array $map */ $map = $this->map; foreach ($map as &$value) { // $value can be true in the case of the use of a Compound matcher @@ -132,7 +113,9 @@ private function getReverseMap($defaultSiteAccess) $value = $defaultSiteAccess; } } + /** @var array $map */ + /** @var array */ return $this->reverseMap = array_flip($map); } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Host.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Host.php index b629c409d5..a5f7e543e7 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Host.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Host.php @@ -9,6 +9,7 @@ use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map; +use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; class Host extends Map { @@ -22,16 +23,16 @@ public function getName(): string * * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request */ - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { - if (!$this->key) { + if (!isset($this->key)) { $this->setMapKey((string)$request->getHost()); } parent::setRequest($request); } - public function reverseMatch($siteAccessName) + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { $matcher = parent::reverseMatch($siteAccessName); if ($matcher instanceof self) { diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Port.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Port.php index 75f6d0d0d3..a191623670 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Port.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/Port.php @@ -9,9 +9,22 @@ use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map; +use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; class Port extends Map { + /** + * @param array $map + */ + public function __construct(array $map) + { + $normalizedMap = []; + foreach ($map as $key => $value) { + $normalizedMap[(string)$key] = $value; + } + parent::__construct($normalizedMap); + } + public function getName(): string { return 'port'; @@ -22,22 +35,13 @@ public function getName(): string * * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request */ - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { - if (!$this->key) { - if (!empty($request->getPort())) { - $key = $request->getPort(); - } else { - switch ($request->getScheme()) { - case 'https': - $key = 443; - break; - - case 'http': - default: - $key = 80; - } - } + if (!isset($this->key)) { + $key = $request->getPort() ?? match ($request->getScheme()) { + 'https' => 443, + default => 80, + }; $this->setMapKey((string)$key); } @@ -45,7 +49,7 @@ public function setRequest(SimplifiedRequest $request) parent::setRequest($request); } - public function reverseMatch($siteAccessName) + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { $matcher = parent::reverseMatch($siteAccessName); if ($matcher instanceof self) { diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/URI.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/URI.php index a940b8bb8c..b4f37ca867 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/URI.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Map/URI.php @@ -10,6 +10,7 @@ use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Map; use Ibexa\Core\MVC\Symfony\SiteAccess\URILexer; +use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; class URI extends Map implements URILexer { @@ -18,9 +19,9 @@ class URI extends Map implements URILexer * * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request */ - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { - if (!$this->key) { + if (!isset($this->key)) { sscanf((string)$request->getPathInfo(), '/%[^/]', $key); $this->setMapKey(rawurldecode((string)$key)); } @@ -76,12 +77,12 @@ public function analyseLink($linkUri): string return "/{$this->key}{$joiningSlash}{$linkUri}{$queryString}"; } - public function reverseMatch($siteAccessName) + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { $matcher = parent::reverseMatch($siteAccessName); if ($matcher instanceof self) { $request = $matcher->getRequest(); - // Clean up "old" siteaccess prefix and add the new prefix. + // Clean up the "old" SiteAccess prefix and add the new prefix. $request->setPathinfo($this->analyseLink((string)$request->getPathInfo())); } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/Regex.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/Regex.php index a00d04cf09..8a35c26cb0 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/Regex.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/Regex.php @@ -14,38 +14,28 @@ abstract class Regex implements Matcher { /** * Element that will be matched against the regex. - * - * @var string */ - protected $element; + protected ?string $element = null; /** * Regular expression used for matching. - * - * @var string */ - protected $regex; + protected string $regex; /** * Item number to pick in regex. - * - * @var string */ - protected $itemNumber; + protected int $itemNumber; - /** @var \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest */ - protected $request; + protected SimplifiedRequest $request; - /** @var string */ - protected $matchedSiteAccess; + protected string|false $matchedSiteAccess; /** - * Constructor. - * * @param string $regex Regular Expression to use. * @param int $itemNumber Item number to pick in regex. */ - public function __construct($regex, $itemNumber) + public function __construct(string $regex, int $itemNumber) { $this->regex = $regex; $this->itemNumber = $itemNumber; @@ -56,25 +46,23 @@ public function __sleep() return ['regex', 'itemNumber', 'matchedSiteAccess']; } - public function match() + public function match(): string|bool { return $this->getMatchedSiteAccess(); } /** * Returns matched SiteAccess. - * - * @return string|bool */ - protected function getMatchedSiteAccess() + protected function getMatchedSiteAccess(): string|false { if (isset($this->matchedSiteAccess)) { return $this->matchedSiteAccess; } preg_match( - "@{$this->regex}@", - (string)$this->element, + "@$this->regex@", + $this->element, $match ); @@ -88,18 +76,26 @@ protected function getMatchedSiteAccess() * * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request */ - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { $this->request = $request; } /** - * Injects element to match against with the regexp. - * - * @param string $element + * Injects an element to match against with the regexp. */ - public function setMatchElement($element) + public function setMatchElement(string $element): void { $this->element = $element; } + + public function getRegex(): string + { + return $this->regex; + } + + public function getItemNumber(): int + { + return $this->itemNumber; + } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/URIElement.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/URIElement.php index 49dddd748a..a35904d16d 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/URIElement.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/URIElement.php @@ -7,6 +7,7 @@ namespace Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; +use Ibexa\Core\Base\Exceptions\BadStateException; use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; use Ibexa\Core\MVC\Symfony\SiteAccess\URILexer; use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; @@ -14,33 +15,28 @@ class URIElement implements VersatileMatcher, URILexer { - /** @var \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest */ - private $request; + private ?SimplifiedRequest $request = null; /** * Number of elements to take into account. - * - * @var int */ - private $elementNumber; + private int $elementNumber; /** * URI elements used for matching as an array. * - * @var array + * @var array */ - private $uriElements; + private array $uriElements; /** - * Constructor. - * - * @param int|array $elementNumber Number of elements to take into account. + * @param array|int $elementNumber Number of elements to take into account. */ - public function __construct($elementNumber) + public function __construct(array|int $elementNumber) { if (is_array($elementNumber)) { // DI config parser will create an array with 'value' => number - $elementNumber = current($elementNumber); + $elementNumber = (int)current($elementNumber); } $this->elementNumber = (int)$elementNumber; @@ -52,15 +48,15 @@ public function __sleep() } /** - * Returns matching Siteaccess. + * Returns matching SiteAccess. * - * @return string|false Siteaccess matched or false. + * @return string|false SiteAccess matched or false. */ - public function match() + public function match(): string|bool { try { return implode('_', $this->getURIElements()); - } catch (LogicException $e) { + } catch (LogicException) { return false; } } @@ -70,18 +66,20 @@ public function match() * * @throws \LogicException * - * @return array + * @return string[] */ - protected function getURIElements() + public function getURIElements(): array { if (isset($this->uriElements)) { return $this->uriElements; - } elseif (!isset($this->request)) { + } + + if (!isset($this->request)) { return []; } $elements = array_slice( - explode('/', $this->request->getPathInfo()), + explode('/', (string)$this->request->getPathInfo()), 1, $this->elementNumber ); @@ -110,32 +108,42 @@ public function getName(): string * * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request */ - public function setRequest(SimplifiedRequest $request) + public function setRequest(SimplifiedRequest $request): void { $this->request = $request; } /** - * @return \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the request is not set */ - public function getRequest() + public function getRequest(): SimplifiedRequest { + if (null === $this->request) { + throw new BadStateException( + 'request', + sprintf( + 'Missing required request context in %s matcher', + __CLASS__ + ) + ); + } + return $this->request; } /** - * Analyses $uri and removes the siteaccess part, if needed. + * Analyzes $uri and removes the SiteAccess part, if needed. * * @param string $uri The original URI * * @return string The modified URI */ - public function analyseURI($uri) + public function analyseURI($uri): string { $uriElements = '/' . implode('/', $this->getURIElements()); - if ($uri == $uriElements) { + if ($uri === $uriElements) { $uri = ''; - } elseif (strpos($uri, $uriElements) === 0) { + } elseif (str_starts_with($uri, $uriElements)) { $uri = mb_substr($uri, mb_strlen($uriElements)); } @@ -143,7 +151,7 @@ public function analyseURI($uri) } /** - * Analyses $linkUri when generating a link to a route, in order to have the siteaccess part back in the URI. + * Analyses $linkUri when generating a link to a route, in order to have the SiteAccess part back in the URI. * * @param string $linkUri * @@ -156,31 +164,46 @@ public function analyseLink($linkUri): string $linkUri = ltrim($linkUri, '/'); $uriElements = implode('/', $this->getURIElements()); - return "/{$uriElements}{$joiningSlash}{$linkUri}"; + return sprintf('/%s%s%s', $uriElements, $joiningSlash, $linkUri); } /** - * Returns matcher object corresponding to $siteAccessName or null if non applicable. + * Returns matcher object corresponding to $siteAccessName or null if non-applicable. * * Limitation: If the element number is > 1, we cannot predict how URI segments are expected to be built. * So we expect "_" will be reversed to "/" - * e.g. foo_bar => foo/bar with elementNumber == 2 - * Hence if number of elements is different than the element number, we report as non matched. + * e.g., foo_bar => foo/bar with elementNumber == 2 + * Hence if number of elements is different from the element number, we report as non-matched. * * @param string $siteAccessName * * @return \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIElement|null + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if request is not set */ - public function reverseMatch($siteAccessName) + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { $elements = $this->elementNumber > 1 ? explode('_', $siteAccessName) : [$siteAccessName]; if (count($elements) !== $this->elementNumber) { return null; } - $pathinfo = '/' . implode('/', $elements) . '/' . ltrim((string)$this->request->getPathInfo(), '/'); - $this->request->setPathinfo($pathinfo); + $pathInfo = '/' . implode('/', $elements) . '/' . ltrim((string)$this->getRequest()->getPathInfo(), '/'); + $this->getRequest()->setPathinfo($pathInfo); return $this; } + + public function getElementNumber(): int + { + return $this->elementNumber; + } + + /** + * @param string[] $uriElements + */ + public function setUriElements(array $uriElements): void + { + $this->uriElements = $uriElements; + } } diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/URIText.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/URIText.php index eeef01066e..835f1bd319 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/URIText.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/URIText.php @@ -30,7 +30,7 @@ public function getName(): string public function setRequest(SimplifiedRequest $request): void { - if (!$this->element) { + if (!isset($this->element)) { $this->setMatchElement((string)$request->getPathInfo()); } @@ -52,7 +52,7 @@ public function analyseLink($linkUri): string return $siteAccessUri . $linkUri; } - public function reverseMatch($siteAccessName): ?VersatileMatcher + public function reverseMatch(string $siteAccessName): ?VersatileMatcher { $this->request->setPathinfo("/{$this->prefix}{$siteAccessName}{$this->suffix}{$this->request->getPathInfo()}"); diff --git a/src/lib/MVC/Symfony/SiteAccess/VersatileMatcher.php b/src/lib/MVC/Symfony/SiteAccess/VersatileMatcher.php index 0445e2e9b6..556da9206e 100644 --- a/src/lib/MVC/Symfony/SiteAccess/VersatileMatcher.php +++ b/src/lib/MVC/Symfony/SiteAccess/VersatileMatcher.php @@ -7,6 +7,8 @@ namespace Ibexa\Core\MVC\Symfony\SiteAccess; +use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; + /** * Interface for SiteAccess matchers. * @@ -16,23 +18,19 @@ interface VersatileMatcher extends Matcher { /** - * Returns matcher object corresponding to $siteAccessName or null if non applicable. - * - * Note: VersatileMatcher objects always receive a request with cleaned up pathinfo (i.e. no SiteAccess part inside). + * Returns a matcher object corresponding to $siteAccessName or null if non-applicable. * - * @param string $siteAccessName + * Note: VersatileMatcher objects always receive a request with cleaned-up pathInfo (i.e. no SiteAccess part inside). * - * @return \Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher|null Typically the current matcher, with updated request. + * @return \Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher|null Typically the current matcher, with an updated request. */ - public function reverseMatch($siteAccessName); + public function reverseMatch(string $siteAccessName): ?VersatileMatcher; /** * Returns the SimplifiedRequest object corresponding to the reverse match. * This request object can then be used to build a link to the "reverse matched" SiteAccess. * * @see reverseMatch() - * - * @return \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest */ - public function getRequest(); + public function getRequest(): SimplifiedRequest; } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php index f496e68738..c7c67b26f6 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php @@ -13,45 +13,66 @@ use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound; use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\CompoundStub; use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\MatcherStub; -use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use PHPUnit\Framework\TestCase; -use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; -use Symfony\Component\Serializer\Serializer; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +/** + * @covers \Ibexa\Core\MVC\Symfony\Component\Serializer\CompoundMatcherNormalizer + * + * @phpstan-type TNormalizedData array{type?: class-string, subMatchers: array, config: array, matchersMap: array} + */ final class CompoundMatcherNormalizerTest extends TestCase { - public function testNormalization(): void + /** @phpstan-var TNormalizedData */ + private const array DATA = [ + 'type' => CompoundStub::class, + 'subMatchers' => [ + 'foo' => ['type' => MatcherStub::class, 'data' => 'foo'], + 'bar' => ['type' => MatcherStub::class, 'data' => 'bar'], + 'baz' => ['type' => MatcherStub::class, 'data' => 'baz'], + ], + 'config' => [], + 'matchersMap' => [], + ]; + + /** + * @phpstan-return TNormalizedData + * + * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface + */ + public function testNormalization(): array { $matcher = new CompoundStub([]); + $subMatchers = $this->getSubMatchers(); $matcher->setSubMatchers( - [ - 'foo' => new MatcherStub('foo'), - 'bar' => new MatcherStub('bar'), - 'baz' => new MatcherStub('baz'), - ] + $subMatchers ); $normalizer = new CompoundMatcherNormalizer(); - $serializer = new Serializer( - [ - $normalizer, - new SerializerStub(), - new ObjectNormalizer(), - ] - ); + $innerNormalizerMock = $this->createMock(NormalizerInterface::class); + $innerNormalizerMock + ->expects(self::once()) + ->method('normalize') + ->with($subMatchers, null, []) + ->willReturn( + [ + 'foo' => ['type' => MatcherStub::class, 'data' => 'foo'], + 'bar' => ['type' => MatcherStub::class, 'data' => 'bar'], + 'baz' => ['type' => MatcherStub::class, 'data' => 'baz'], + ] + ); + + $normalizer->setNormalizer($innerNormalizerMock); + $actualNormalizedData = $normalizer->normalize($matcher); self::assertEquals( - [ - 'subMatchers' => [ - 'foo' => ['data' => 'foo'], - 'bar' => ['data' => 'bar'], - 'baz' => ['data' => 'baz'], - ], - 'config' => [], - 'matchersMap' => [], - ], - $serializer->normalize($matcher) + self::DATA, + $actualNormalizedData ); + + /** @phpstan-var TNormalizedData */ + return $actualNormalizedData; } public function testSupportsNormalization(): void @@ -63,24 +84,65 @@ public function testSupportsNormalization(): void } /** - * @throws \JsonException + * @phpstan-return iterable */ - public function testSupportsDenormalization(): void + public static function getDataForSupportsNormalization(): iterable + { + yield [self::DATA, Compound::class, true]; + yield [self::DATA, Matcher::class, false]; + + $dataWithMissingType = self::DATA; + unset($dataWithMissingType['type']); + + yield [$dataWithMissingType, Compound::class, false]; + } + + /** + * @dataProvider getDataForSupportsNormalization + * + * @phpstan-param TNormalizedData $data + * @phpstan-param class-string $type + */ + public function testSupportsDenormalization(array $data, string $type, bool $supports): void { $normalizer = new CompoundMatcherNormalizer(); - $data = json_encode( - [ - 'subMatchers' => [ - 'foo' => ['data' => 'foo'], - ], - 'config' => [], - 'matchersMap' => [], - ], - JSON_THROW_ON_ERROR - ); + self::assertSame($supports, $normalizer->supportsDenormalization($data, $type)); + } - self::assertTrue($normalizer->supportsDenormalization($data, Compound::class, 'json')); - self::assertFalse($normalizer->supportsDenormalization($data, Matcher::class, 'json')); + /** + * @depends testNormalization + * + * @phpstan-param array{type: class-string, subMatchers: array, config: array{}, matchersMap: array{}} $data + * + * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface + */ + public function testDenormalization(array $data): void + { + $expectedCompoundMatcher = new CompoundStub($this->getSubMatchers()); + $normalizer = new CompoundMatcherNormalizer(); + $innerDenormalizerMock = $this->createMock(DenormalizerInterface::class); + $innerDenormalizerMock + ->expects(self::exactly(count($data['subMatchers']))) + ->method('denormalize') + ->willReturnCallback( + static fn (array $data): Matcher => new MatcherStub($data['data'] ?? []) + ); + $normalizer->setDenormalizer($innerDenormalizerMock); + $actualCompoundMatcher = $normalizer->denormalize($data, Compound::class); + + self::assertEquals($expectedCompoundMatcher, $actualCompoundMatcher); + } + + /** + * @return array + */ + private function getSubMatchers(): array + { + return [ + 'foo' => new MatcherStub('foo'), + 'bar' => new MatcherStub('bar'), + 'baz' => new MatcherStub('baz'), + ]; } } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php index 8f2ace75c3..9f97defcfc 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php @@ -21,6 +21,17 @@ */ final class HostElementNormalizerTest extends TestCase { + private const array DATA = [ + 'elementNumber' => 2, + 'hostElements' => [ + 'ibexa', + 'dev', + ], + ]; + + /** + * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface + */ public function testNormalization(): void { $normalizer = new HostElementNormalizer(); @@ -33,17 +44,11 @@ public function testNormalization(): void $matcher = new HostElement(2); // Set request and invoke match to initialize HostElement::$hostElements - $matcher->setRequest(SimplifiedRequest::fromUrl('http://ibexa.dev/foo/bar')); + $matcher->setRequest(SimplifiedRequest::fromUrl('https://ibexa.dev/foo/bar')); $matcher->match(); self::assertEquals( - [ - 'elementNumber' => 2, - 'hostElements' => [ - 'ibexa', - 'dev', - ], - ], + self::DATA, $serializer->normalize($matcher) ); } @@ -55,4 +60,17 @@ public function testSupportsNormalization(): void self::assertTrue($normalizer->supportsNormalization($this->createMock(HostElement::class))); self::assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class))); } + + /** + * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface + */ + public function testDenormalization(): void + { + $denormalizer = new HostElementNormalizer(); + $expectedHostElement = new HostElement(2); + $expectedHostElement->setRequest(SimplifiedRequest::fromUrl('https://ibexa.dev/foo/bar')); + $actualHostElement = $denormalizer->denormalize(self::DATA, HostElement::class); + + self::assertSame('dev', $actualHostElement->match()); + } } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/MapNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/MapNormalizerTest.php index e507124a21..e605db860b 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/MapNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/MapNormalizerTest.php @@ -27,6 +27,7 @@ public function testNormalization(): void 'key' => 'foo', 'map' => [], 'reverseMap' => [], + 'type' => $matcher::class, ], $normalizer->normalize($matcher) ); diff --git a/tests/lib/MVC/Symfony/Component/Serializer/RegexNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/RegexNormalizerTest.php index 7ddcf91f29..30a3ad4259 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/RegexNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/RegexNormalizerTest.php @@ -25,7 +25,7 @@ public function testNormalize(): void [ 'regex' => '/^Foo(.*)/(.*)/', 'itemNumber' => 2, - 'matchedSiteAccess' => null, + 'type' => RegexMatcherStub::class, ], $normalizer->normalize($matcher) ); diff --git a/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php index da30ae9699..429c49e8a8 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php @@ -12,6 +12,9 @@ use PHPUnit\Framework\TestCase; use stdClass; +/** + * @covers \Ibexa\Core\MVC\Symfony\Component\Serializer\SimplifiedRequestNormalizer + */ final class SimplifiedRequestNormalizerTest extends TestCase { /** @@ -42,7 +45,7 @@ public function testNormalize(): void 'scheme' => 'http', 'host' => 'www.example.com', 'port' => 8080, - 'pathinfo' => '/foo', + 'pathInfo' => '/foo', 'queryParams' => ['param' => 'value', 'this' => 'that'], 'headers' => [], 'languages' => ['pl-PL', 'en-US'], @@ -74,7 +77,7 @@ public function testNormalizeWithNewConstructor(): void 'scheme' => 'http', 'host' => 'www.example.com', 'port' => 8080, - 'pathinfo' => '/foo', + 'pathInfo' => '/foo', 'queryParams' => ['param' => 'value', 'this' => 'that'], 'headers' => [], 'languages' => ['pl-PL', 'en-US'], diff --git a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/CompoundStub.php b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/CompoundStub.php index fa3e894fe0..64179f75ce 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/CompoundStub.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/CompoundStub.php @@ -11,20 +11,32 @@ use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound; +/** + * @phpstan-import-type TCompoundMatcherConfig from \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound + */ final class CompoundStub extends Compound { + /** + * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher[] $subMatchers + */ public function __construct(array $subMatchers) { parent::__construct([]); $this->subMatchers = $subMatchers; } - public function match() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException + */ + public function match(): never { throw new NotImplementedException(__METHOD__); } - public function reverseMatch($siteAccessName) + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException + */ + public function reverseMatch(string $siteAccessName): never { throw new NotImplementedException(__METHOD__); } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/MatcherStub.php b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/MatcherStub.php index 93df93a591..fca21b7126 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/MatcherStub.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/MatcherStub.php @@ -14,30 +14,38 @@ final class MatcherStub implements Matcher { - /** @var mixed */ - private $data; + private mixed $data; - public function __construct($data = null) + public function __construct(mixed $data = null) { $this->data = $data; } - public function setRequest(SimplifiedRequest $request) + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException + */ + public function setRequest(SimplifiedRequest $request): never { throw new NotImplementedException(__METHOD__); } - public function match() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException + */ + public function match(): never { throw new NotImplementedException(__METHOD__); } - public function getName() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException + */ + public function getName(): never { throw new NotImplementedException(__METHOD__); } - public function getData() + public function getData(): mixed { return $this->data; } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/RegexMatcher.php b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/RegexMatcher.php index 5ce34687a8..d00096cd2b 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/RegexMatcher.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/RegexMatcher.php @@ -13,7 +13,10 @@ final class RegexMatcher extends BaseRegex { - public function getName() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException + */ + public function getName(): never { throw new NotImplementedException(__METHOD__); } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php deleted file mode 100644 index 3a2828469e..0000000000 --- a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php +++ /dev/null @@ -1,56 +0,0 @@ - $value) { - $result[$key] = $this->normalize($value, $format, $context); - } - - return $result; - } - - if ($object instanceof MatcherStub) { - return [ - 'data' => $object->getData(), - ]; - } - - return $object; - } - - public function supportsNormalization($data, string $format = null): bool - { - return $data instanceof MatcherStub; - } -} diff --git a/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php index 6607fa1901..c768e42e35 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php @@ -16,8 +16,14 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; +/** + * @covers \Ibexa\Core\MVC\Symfony\Component\Serializer\URIElementNormalizer + */ final class URIElementNormalizerTest extends TestCase { + /** + * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface + */ public function testNormalization(): void { $normalizer = new URIElementNormalizer(); @@ -30,7 +36,7 @@ public function testNormalization(): void $matcher = new URIElement(2); // Set request and invoke match to initialize HostElement::$hostElements - $matcher->setRequest(SimplifiedRequest::fromUrl('http://ezpublish.dev/foo/bar')); + $matcher->setRequest(SimplifiedRequest::fromUrl('http://ibexa.dev/foo/bar')); $matcher->match(); self::assertEquals( diff --git a/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php index e3ebe2fea9..49df925576 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php @@ -15,8 +15,14 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; +/** + * @covers \Ibexa\Core\MVC\Symfony\Component\Serializer\URITextNormalizer + */ final class URITextNormalizerTest extends TestCase { + /** + * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface + */ public function testNormalize(): void { $normalizer = new URITextNormalizer(); diff --git a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php index 8db7c5688b..63db1fe238 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php @@ -15,12 +15,12 @@ use Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilder; use Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilderInterface; use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class CompoundAndTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $matcherBuilder; + private MatcherBuilderInterface & MockObject $matcherBuilder; protected function setUp(): void { @@ -28,10 +28,7 @@ protected function setUp(): void $this->matcherBuilder = $this->createMock(MatcherBuilderInterface::class); } - /** - * @return \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound\LogicalAnd - */ - public function testConstruct() + public function testConstruct(): LogicalAnd { return $this->buildMatcher(); } @@ -39,7 +36,7 @@ public function testConstruct() /** * @return \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound\LogicalAnd */ - private function buildMatcher() + private function buildMatcher(): LogicalAnd { return new LogicalAnd( [ @@ -71,7 +68,7 @@ private function buildMatcher() /** * @depends testConstruct */ - public function testSetMatcherBuilder(Compound $compoundMatcher) + public function testSetMatcherBuilder(Compound $compoundMatcher): void { $this ->matcherBuilder @@ -94,7 +91,7 @@ public function testSetMatcherBuilder(Compound $compoundMatcher) * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request * @param $expectedMatch */ - public function testMatch(SimplifiedRequest $request, $expectedMatch) + public function testMatch(SimplifiedRequest $request, $expectedMatch): void { $compoundMatcher = $this->buildMatcher(); $compoundMatcher->setRequest($request); @@ -102,7 +99,7 @@ public function testMatch(SimplifiedRequest $request, $expectedMatch) self::assertSame($expectedMatch, $compoundMatcher->match()); } - public function testSetRequest() + public function testSetRequest(): void { $compoundMatcher = new LogicalAnd( [ @@ -138,7 +135,7 @@ public function testSetRequest() $compoundMatcher->setRequest($request); } - public function matchProvider() + public function matchProvider(): array { return [ [SimplifiedRequest::fromUrl('http://fr.ezpublish.dev/eng'), 'fr_eng'], @@ -152,7 +149,7 @@ public function matchProvider() ]; } - public function testReverseMatchSiteAccessNotConfigured() + public function testReverseMatchSiteAccessNotConfigured(): void { $compoundMatcher = $this->buildMatcher(); $this->matcherBuilder @@ -165,7 +162,7 @@ public function testReverseMatchSiteAccessNotConfigured() self::assertNull($compoundMatcher->reverseMatch('not_configured_sa')); } - public function testReverseMatchNotVersatile() + public function testReverseMatchNotVersatile(): void { $request = $this->createMock(SimplifiedRequest::class); $siteAccessName = 'fr_eng'; @@ -215,7 +212,7 @@ public function testReverseMatchNotVersatile() self::assertNull($compoundMatcher->reverseMatch($siteAccessName)); } - public function testReverseMatchFail() + public function testReverseMatchFail(): void { $request = $this->createMock(SimplifiedRequest::class); $siteAccessName = 'fr_eng'; @@ -263,7 +260,7 @@ public function testReverseMatchFail() self::assertNull($compoundMatcher->reverseMatch($siteAccessName)); } - public function testReverseMatch() + public function testReverseMatch(): void { $request = $this->createMock(SimplifiedRequest::class); $siteAccessName = 'fr_eng'; @@ -317,7 +314,7 @@ public function testReverseMatch() } } - public function testSerialize() + public function testSerialize(): void { $matcher = new LogicalAnd([]); $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar')); diff --git a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php index dad491048d..47d2d38759 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php @@ -15,12 +15,12 @@ use Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilder; use Ibexa\Core\MVC\Symfony\SiteAccess\MatcherBuilderInterface; use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class CompoundOrTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $matcherBuilder; + private MatcherBuilderInterface & MockObject $matcherBuilder; protected function setUp(): void { @@ -58,7 +58,7 @@ private function buildMatcher(): LogicalOr /** * @depends testConstruct */ - public function testSetMatcherBuilder(Compound $compoundMatcher) + public function testSetMatcherBuilder(Compound $compoundMatcher): void { $this->matcherBuilder ->expects(self::any()) @@ -80,7 +80,7 @@ public function testSetMatcherBuilder(Compound $compoundMatcher) * @param \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest $request * @param string $expectedMatch */ - public function testMatch(SimplifiedRequest $request, $expectedMatch) + public function testMatch(SimplifiedRequest $request, $expectedMatch): void { $compoundMatcher = $this->buildMatcher(); $compoundMatcher->setRequest($request); @@ -88,7 +88,7 @@ public function testMatch(SimplifiedRequest $request, $expectedMatch) self::assertSame($expectedMatch, $compoundMatcher->match()); } - public function matchProvider() + public function matchProvider(): array { return [ [SimplifiedRequest::fromUrl('http://fr.ezpublish.dev/eng'), 'fr_eng'], @@ -103,7 +103,7 @@ public function matchProvider() ]; } - public function testReverseMatchSiteAccessNotConfigured() + public function testReverseMatchSiteAccessNotConfigured(): void { $compoundMatcher = $this->buildMatcher(); $this->matcherBuilder @@ -116,7 +116,7 @@ public function testReverseMatchSiteAccessNotConfigured() self::assertNull($compoundMatcher->reverseMatch('not_configured_sa')); } - public function testReverseMatchNotVersatile() + public function testReverseMatchNotVersatile(): void { $request = $this->createMock(SimplifiedRequest::class); $siteAccessName = 'fr_eng'; @@ -167,7 +167,7 @@ public function testReverseMatchNotVersatile() self::assertNull($compoundMatcher->reverseMatch($siteAccessName)); } - public function testReverseMatchFail() + public function testReverseMatchFail(): void { $request = $this->createMock(SimplifiedRequest::class); $siteAccessName = 'fr_eng'; @@ -215,7 +215,7 @@ public function testReverseMatchFail() self::assertNull($compoundMatcher->reverseMatch($siteAccessName)); } - public function testReverseMatch1() + public function testReverseMatch1(): void { $request = $this->createMock(SimplifiedRequest::class); $siteAccessName = 'fr_eng'; @@ -266,7 +266,7 @@ public function testReverseMatch1() } } - public function testReverseMatch2() + public function testReverseMatch2(): void { $request = $this->createMock(SimplifiedRequest::class); $siteAccessName = 'fr_eng'; @@ -319,7 +319,7 @@ public function testReverseMatch2() } } - public function testSerialize() + public function testSerialize(): void { $matcher = new LogicalOr([]); $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar')); diff --git a/tests/lib/MVC/Symfony/SiteAccess/MatcherSerializationTest.php b/tests/lib/MVC/Symfony/SiteAccess/MatcherSerializationTest.php index 4a053016fc..8b73547781 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/MatcherSerializationTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/MatcherSerializationTest.php @@ -9,6 +9,8 @@ use Ibexa\Core\MVC\Symfony\Component\Serializer\SerializerTrait; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; +use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound\LogicalAnd; +use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Compound\LogicalOr; use PHPUnit\Framework\TestCase; class MatcherSerializationTest extends TestCase @@ -16,33 +18,20 @@ class MatcherSerializationTest extends TestCase use SerializerTrait; /** - * @param \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher|null $expected - * * @dataProvider matcherProvider */ - public function testDeserialize(Matcher $matcher, $expected = null): void + public function testDeserialize(Matcher $matcher, Matcher $expected = null): void { $serializedMatcher = $this->serializeMatcher($matcher); $context = []; - // BC layer - if ($matcher instanceof Matcher\CompoundInterface) { - $subMatchers = $matcher->getSubMatchers(); - foreach ($subMatchers as $subMatcher) { - $context['serialized_siteaccess_sub_matchers'][get_class($subMatcher)] = $this->serializeMatcher($subMatcher); - } - } - // -- - $unserializedMatcher = $this->deserializeMatcher($serializedMatcher, get_class($matcher), $context); + $deserializeMatcher = $this->deserializeMatcher($serializedMatcher, get_class($matcher), $context); $expected = $expected ?? $matcher; - self::assertEquals($expected, $unserializedMatcher); + self::assertEquals($expected, $deserializeMatcher); } - /** - * @return string - */ - private function serializeMatcher(Matcher $matcher) + private function serializeMatcher(Matcher $matcher): string { return $this->getSerializer()->serialize( $matcher, @@ -69,34 +58,34 @@ private function deserializeMatcher(string $serializedMatcher, string $matcherFQ public function matcherProvider(): iterable { $subMatchers = [ - Matcher\Map\URI::class => new Matcher\Map\URI(['map' => ['key' => 'value']]), - Matcher\Map\Host::class => new Matcher\Map\Host(['map' => ['key' => 'value']]), + Matcher\Map\URI::class => new Matcher\Map\URI(['campaign' => 'event']), + Matcher\Map\Host::class => new Matcher\Map\Host(['www.example.org' => 'site']), + Matcher\HostElement::class => new Matcher\HostElement(1), ]; // data truncated due to https://issues.ibexa.co/browse/EZP-31810 $expectedSubMatchers = [ Matcher\Map\URI::class => new Matcher\Map\URI([]), Matcher\Map\Host::class => new Matcher\Map\Host([]), + Matcher\HostElement::class => new Matcher\HostElement(1), ]; - $logicalAnd = new Matcher\Compound\LogicalAnd( + $compoundMatcherConfig = [ [ - [ - 'match' => 'site_access_name', + 'matchers' => [ + Matcher\Map\URI::class => ['match' => 'site_access_name'], + Matcher\Map\Host::class => ['match' => 'site_access_name'], + Matcher\HostElement::class => ['match' => 'site_access_name'], ], - ] - ); + 'match' => 'site_access_name', + ], + ]; + $logicalAnd = new LogicalAnd($compoundMatcherConfig); $logicalAnd->setSubMatchers($subMatchers); - $expectedLogicalAnd = new Matcher\Compound\LogicalAnd([]); + $expectedLogicalAnd = new LogicalAnd([]); $expectedLogicalAnd->setSubMatchers($expectedSubMatchers); - $logicalOr = new Matcher\Compound\LogicalOr( - [ - [ - 'match' => 'site_access_name', - ], - ] - ); + $logicalOr = new LogicalOr($compoundMatcherConfig); $logicalOr->setSubMatchers($subMatchers); - $expectedLogicalOr = new Matcher\Compound\LogicalOr([]); + $expectedLogicalOr = new LogicalOr([]); $expectedLogicalOr->setSubMatchers($expectedSubMatchers); $expectedMapURI = new Matcher\Map\URI([]); @@ -150,11 +139,11 @@ public function matcherProvider(): iterable */ private function getMapPortMatcherTestCase(): array { - $matcherBeforeSerialization = new Matcher\Map\Port(['map' => ['key' => 'value']]); - $matcherBeforeSerialization->setMapKey('map'); + $matcherBeforeSerialization = new Matcher\Map\Port(['8080' => 'event']); + $matcherBeforeSerialization->setMapKey('8080'); $matcherAfterDeserialization = new Matcher\Map\Port([]); - $matcherAfterDeserialization->setMapKey('map'); + $matcherAfterDeserialization->setMapKey('8080'); return [$matcherBeforeSerialization, $matcherAfterDeserialization]; } @@ -164,7 +153,7 @@ private function getMapPortMatcherTestCase(): array */ private function getMapHostMatcherTestCase(): array { - $matcherBeforeSerialization = new Matcher\Map\Host(['map' => ['key' => 'value']]); + $matcherBeforeSerialization = new Matcher\Map\Host(['map' => 'site']); $matcherBeforeSerialization->setMapKey('map'); $matcherAfterDeserialization = new Matcher\Map\Host([]); @@ -178,11 +167,11 @@ private function getMapHostMatcherTestCase(): array */ private function getMapURIMatcherTestCase(): array { - $matcherBeforeSerialization = new Matcher\Map\URI(['map' => ['key' => 'value']]); - $matcherBeforeSerialization->setMapKey('map'); + $matcherBeforeSerialization = new Matcher\Map\URI(['www.example.org' => 'event_site']); + $matcherBeforeSerialization->setMapKey('www.example.org'); $matcherAfterDeserialization = new Matcher\Map\URI([]); - $matcherAfterDeserialization->setMapKey('map'); + $matcherAfterDeserialization->setMapKey('www.example.org'); return [$matcherBeforeSerialization, $matcherAfterDeserialization]; } diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php b/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php index 7e9d96c9c8..17ed9f9051 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php @@ -151,7 +151,7 @@ public function testReverseMatchPort() $result = $matcher->reverseMatch('ibexa_demo_site'); self::assertInstanceOf(Port::class, $result); self::assertSame($request, $matcher->getRequest()); - self::assertSame(8000, $result->getMapKey()); + self::assertSame('8000', $result->getMapKey()); self::assertSame(8000, $result->getRequest()->getPort()); self::assertSame('http', $result->getRequest()->getScheme()); } From 8cd0448460b186a95499a6c956855114466497d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 20:55:23 +0200 Subject: [PATCH 12/26] fixup! [doctrine/dbal] Fixed usage of deprecated \Doctrine\DBAL\Query\QueryBuilder::execute method --- tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php b/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php index 89b56a4764..8d30bf2e20 100644 --- a/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php +++ b/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php @@ -191,7 +191,7 @@ public function testDeletedirectory(): void $this->qbMock ->expects(self::once()) - ->method('execute') + ->method('executeStatement') ->willReturn(1); $this->handler->deleteDirectory('images/_alias/subfolder/'); @@ -246,7 +246,7 @@ private function setupQueryBuilderLoad(int $rowCount, ?array $result): void ->willReturnSelf(); $this->qbMock - ->method('execute') + ->method('executeQuery') ->willReturn($resultMock); } } From fe19f70bf0fb5de6469b74909968c48002a622a4 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Tue, 22 Apr 2025 13:54:30 +0200 Subject: [PATCH 13/26] IBX-8471: [Composer] Added doctrine/annotations to "require" section JMS `DefaultPhpFileExtractor` extended by our `ExceptionMessageTemplateFileVisitor` relies on `DocParser` which was moved to the annotations package and discouraged in favor of PHP 8 Attributes --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 368c8457ce..cea2a82a93 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "ext-mbstring": "*", "ext-xsl": "*", "composer/package-versions-deprecated": "^1.11", + "doctrine/annotations": "^2.0", "doctrine/dbal": "^3.7.0", "doctrine/doctrine-bundle": "^2.11.0", "doctrine/orm": "^2.7", From 466b239899a56f42bcba421c6b4420944e6715ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 21:07:08 +0200 Subject: [PATCH 14/26] [doctrine/dbal] Fixed references to removed Doctrine\DBAL\Platforms\{MySqlPlatform,PostgreSqlPlatform} classes --- .../Persistence/Legacy/SharedGateway/GatewayFactoryTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib/Persistence/Legacy/SharedGateway/GatewayFactoryTest.php b/tests/lib/Persistence/Legacy/SharedGateway/GatewayFactoryTest.php index aae86680b7..116107ee04 100644 --- a/tests/lib/Persistence/Legacy/SharedGateway/GatewayFactoryTest.php +++ b/tests/lib/Persistence/Legacy/SharedGateway/GatewayFactoryTest.php @@ -65,8 +65,8 @@ public function getTestBuildSharedGatewayData(): Traversable $databasePlatformGatewayPairs = [ [new Platforms\SqlitePlatform(), SqliteGateway::class], [new Platforms\MySQL80Platform(), FallbackGateway::class], - [new Platforms\MySqlPlatform(), FallbackGateway::class], - [new Platforms\PostgreSqlPlatform(), FallbackGateway::class], + [new Platforms\MySQLPlatform(), FallbackGateway::class], + [new Platforms\PostgreSQLPlatform(), FallbackGateway::class], ]; foreach ($databasePlatformGatewayPairs as $databasePlatformGatewayPair) { From f0419d27550ad03f11ce947d95ce690fa41a0c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 21:14:16 +0200 Subject: [PATCH 15/26] [tests] Adapted Ibexa\Tests\Core\MVC\Symfony\Templating\Twig\Extension\QueryRenderingExtensionTest to Symfony 7 --- .../query_rendering_functions/ibexa_render_content_query.test | 2 +- .../ibexa_render_content_query_esi.test | 2 +- .../query_rendering_functions/ibexa_render_location_query.test | 2 +- .../ibexa_render_location_query_esi.test | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query.test b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query.test index 822184519a..da62c0b631 100644 --- a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query.test +++ b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query.test @@ -13,7 +13,6 @@ return array() array ( 0 => \Symfony\Component\HttpKernel\Controller\ControllerReference::__set_state(array( - 'controller' => 'ibexa_query_render::renderQuery', 'attributes' => array ( 'options' => @@ -28,6 +27,7 @@ array ( 'query' => array ( ), + 'controller' => 'ibexa_query_render::renderQuery', )), 1 => 'inline', 2 => diff --git a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query_esi.test b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query_esi.test index 9f3842ced1..f9fb174c49 100644 --- a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query_esi.test +++ b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_content_query_esi.test @@ -13,7 +13,6 @@ return array() array ( 0 => \Symfony\Component\HttpKernel\Controller\ControllerReference::__set_state(array( - 'controller' => 'ibexa_query_render::renderQuery', 'attributes' => array ( 'options' => @@ -28,6 +27,7 @@ array ( 'query' => array ( ), + 'controller' => 'ibexa_query_render::renderQuery', )), 1 => 'esi', 2 => diff --git a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query.test b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query.test index ce86af76b4..0a46a98a69 100644 --- a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query.test +++ b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query.test @@ -13,7 +13,6 @@ return array() array ( 0 => \Symfony\Component\HttpKernel\Controller\ControllerReference::__set_state(array( - 'controller' => 'ibexa_query_render::renderQuery', 'attributes' => array ( 'options' => @@ -28,6 +27,7 @@ array ( 'query' => array ( ), + 'controller' => 'ibexa_query_render::renderQuery', )), 1 => 'inline', 2 => diff --git a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query_esi.test b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query_esi.test index 24872ce331..a27e8d5175 100644 --- a/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query_esi.test +++ b/tests/lib/MVC/Symfony/Templating/Twig/Extension/_fixtures/query_rendering_functions/ibexa_render_location_query_esi.test @@ -13,7 +13,6 @@ return array() array ( 0 => \Symfony\Component\HttpKernel\Controller\ControllerReference::__set_state(array( - 'controller' => 'ibexa_query_render::renderQuery', 'attributes' => array ( 'options' => @@ -28,6 +27,7 @@ array ( 'query' => array ( ), + 'controller' => 'ibexa_query_render::renderQuery', )), 1 => 'esi', 2 => From b6c252eb76a1d1bd10c355bdebe802bc3198d0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 21:22:33 +0200 Subject: [PATCH 16/26] [tests] Fixed Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\MetadataHandler\LegacyDFSClusterTest::validateConfiguredHandler tests --- .../MetadataHandler/LegacyDFSClusterTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/bundle/IO/DependencyInjection/ConfigurationFactory/MetadataHandler/LegacyDFSClusterTest.php b/tests/bundle/IO/DependencyInjection/ConfigurationFactory/MetadataHandler/LegacyDFSClusterTest.php index 384e18f1df..742118833f 100644 --- a/tests/bundle/IO/DependencyInjection/ConfigurationFactory/MetadataHandler/LegacyDFSClusterTest.php +++ b/tests/bundle/IO/DependencyInjection/ConfigurationFactory/MetadataHandler/LegacyDFSClusterTest.php @@ -10,6 +10,7 @@ use Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory\MetadataHandler\LegacyDFSCluster; use Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactoryTest; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Reference; class LegacyDFSClusterTest extends ConfigurationFactoryTest { @@ -50,7 +51,7 @@ public function validateConfiguredHandler($handlerServiceId) self::assertContainerBuilderHasServiceDefinitionWithArgument( $handlerServiceId, 0, - 'doctrine.dbal.test_connection' + new Reference('doctrine.dbal.test_connection') ); } } From 72882487a41e4cd8aaa76acf82bf22ce477fc6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 21:29:55 +0200 Subject: [PATCH 17/26] [tests] Fixed incompatible \Ibexa\Tests\Integration\RepositoryInstaller\TestCase::$class property type declaration --- tests/integration/RepositoryInstaller/TestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/RepositoryInstaller/TestCase.php b/tests/integration/RepositoryInstaller/TestCase.php index d614b1fb8e..d4bf2f5213 100644 --- a/tests/integration/RepositoryInstaller/TestCase.php +++ b/tests/integration/RepositoryInstaller/TestCase.php @@ -13,7 +13,7 @@ abstract class TestCase extends IbexaKernelTestCase { /** Necessary to allow multiple Kernel classes */ - protected static $class; + protected static ?string $class; protected static function getKernelClass(): string { From b29733ab13f651a5f6005685f6df75c5a19e97f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 21:38:44 +0200 Subject: [PATCH 18/26] [doctrine/dbal] Replaced usage of removed Doctrine\DBAL\Driver\ResultStatement class --- src/lib/Search/Legacy/Content/IndexerGateway.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Search/Legacy/Content/IndexerGateway.php b/src/lib/Search/Legacy/Content/IndexerGateway.php index 504b177026..ccb432c975 100644 --- a/src/lib/Search/Legacy/Content/IndexerGateway.php +++ b/src/lib/Search/Legacy/Content/IndexerGateway.php @@ -10,9 +10,9 @@ use DateTimeInterface; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\QueryBuilder; +use Doctrine\DBAL\Result; use Generator; use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; use Ibexa\Contracts\Core\Search\Content\IndexerGateway as SPIIndexerGateway; @@ -127,12 +127,12 @@ private function buildCountingQuery(QueryBuilder $query): QueryBuilder return $query; } - private function fetchIteration(ResultStatement $statement, int $iterationCount): Generator + private function fetchIteration(Result $result, int $iterationCount): Generator { do { $contentIds = []; for ($i = 0; $i < $iterationCount; ++$i) { - if ($contentId = $statement->fetchOne()) { + if ($contentId = $result->fetchOne()) { $contentIds[] = $contentId; } elseif (empty($contentIds)) { return; From 78c43efe74748f61a949f125cbcda9cf8da741e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 21:42:05 +0200 Subject: [PATCH 19/26] [doctrine/dbal] Removed colons prefix from bound parameter names --- .../User/UserStorage/Gateway/DoctrineStorage.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php index bc896bb27d..4d30aae8a7 100644 --- a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php @@ -331,7 +331,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field): void ':userId' ) ) - ->setParameter(':userId', $versionInfo->contentInfo->id, ParameterType::INTEGER) + ->setParameter('userId', $versionInfo->contentInfo->id, ParameterType::INTEGER) ; $queryBuilder->executeStatement(); @@ -342,15 +342,15 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field): void ->update($this->connection->quoteIdentifier(self::USER_SETTING_TABLE)) ->set('is_enabled', ':isEnabled') ->set('max_login', ':maxLogin') - ->setParameter(':isEnabled', $field->value->externalData['enabled'], ParameterType::INTEGER) - ->setParameter(':maxLogin', $field->value->externalData['maxLogin'], ParameterType::INTEGER) + ->setParameter('isEnabled', $field->value->externalData['enabled'], ParameterType::INTEGER) + ->setParameter('maxLogin', $field->value->externalData['maxLogin'], ParameterType::INTEGER) ->where( $queryBuilder->expr()->eq( $this->connection->quoteIdentifier('user_id'), ':userId' ) ) - ->setParameter(':userId', $versionInfo->contentInfo->id, ParameterType::INTEGER); + ->setParameter('userId', $versionInfo->contentInfo->id, ParameterType::INTEGER); $settingsQuery->executeStatement(); } From 1e83d4550a430b36c4a13ed10fc3b30f3eba2bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sat, 3 May 2025 21:43:36 +0200 Subject: [PATCH 20/26] [doctrine/dbal] Fixed null passed to Doctrine\DBAL\Query\QueryBuilder::setFirstResult --- .../Filter/Gateway/Content/Doctrine/DoctrineGateway.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php b/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php index 3b2afb20a0..ab18a678bd 100644 --- a/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php +++ b/src/lib/Persistence/Legacy/Filter/Gateway/Content/Doctrine/DoctrineGateway.php @@ -226,7 +226,7 @@ private function bulkFetchVersionNames(FilteringQueryBuilder $query): array ) // reset not needed parts, keeping FROM, other JOINs, and WHERE constraints ->setMaxResults(null) - ->setFirstResult(null) + ->setFirstResult(0) ->resetQueryPart('orderBy'); return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); @@ -262,7 +262,7 @@ private function bulkFetchFieldValues(FilteringQueryBuilder $query): array ) // reset not needed parts, keeping FROM, other JOINs, and WHERE constraints ->setMaxResults(null) - ->setFirstResult(null) + ->setFirstResult(0) ->resetQueryPart('orderBy'); return $query->executeQuery()->fetchAll(FetchMode::ASSOCIATIVE); From 960c89172aee40f822a70932739c934e87f89856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Mon, 5 May 2025 15:35:13 +0200 Subject: [PATCH 21/26] fixup! [doctrine/dbal] Fixed usage of deprecated \Doctrine\DBAL\Query\QueryBuilder::execute method --- tests/integration/Core/Repository/URLAliasServiceTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/Core/Repository/URLAliasServiceTest.php b/tests/integration/Core/Repository/URLAliasServiceTest.php index 39376594d0..b7f70ca9f2 100644 --- a/tests/integration/Core/Repository/URLAliasServiceTest.php +++ b/tests/integration/Core/Repository/URLAliasServiceTest.php @@ -1631,20 +1631,20 @@ public function testDeleteCorruptedUrlAliases() $connection = $this->getRawDatabaseConnection(); $query = $connection->createQueryBuilder()->select('*')->from('ezurlalias_ml'); - $originalRows = $query->executeStatement()->fetchAll(PDO::FETCH_ASSOC); + $originalRows = $query->executeQuery()->fetchAllAssociative(); $expectedCount = count($originalRows); $expectedCount += $this->insertBrokenUrlAliasTableFixtures($connection); // sanity check - $updatedRows = $query->executeStatement()->fetchAll(PDO::FETCH_ASSOC); + $updatedRows = $query->executeQuery()->fetchAllAssociative(); self::assertCount($expectedCount, $updatedRows, 'Found unexpected number of new rows'); // BEGIN API use case $urlAliasService->deleteCorruptedUrlAliases(); // END API use case - $updatedRows = $query->executeStatement()->fetchAll(PDO::FETCH_ASSOC); + $updatedRows = $query->executeQuery()->fetchAllAssociative(); self::assertCount( // API should also remove already broken pre-existing URL aliases count($originalRows) - 4, From 4daec812a00a8661d716b9b8a21ae1da65314205 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Tue, 1 Apr 2025 13:33:20 +0200 Subject: [PATCH 22/26] IBX-9811: Refactored Location Doctrine Gateway getSubtreeContent method to remove PDO::FETCH_GROUP usage Extracted getSubtreeContent `$onlyIds` behavior to a separate method as it applies to a different use case on a similar query. --- .../Legacy/Content/Location/Gateway.php | 11 +++++- .../Location/Gateway/DoctrineDatabase.php | 38 +++++++++++++------ .../Location/Gateway/ExceptionConversion.php | 19 +++++++--- .../Legacy/Content/Location/Handler.php | 2 +- .../Legacy/Content/LocationHandlerTest.php | 16 ++++---- 5 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/lib/Persistence/Legacy/Content/Location/Gateway.php b/src/lib/Persistence/Legacy/Content/Location/Gateway.php index 59365b76ab..3e2c7eb7ca 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Gateway.php +++ b/src/lib/Persistence/Legacy/Content/Location/Gateway.php @@ -109,8 +109,17 @@ abstract public function loadParentLocationsDataForDraftContent(int $contentId): /** * Find all content in the given subtree. + * + * @phpstan-return array> + */ + abstract public function getSubtreeContent(int $sourceId): array; + + /** + * Find all content in the given subtree, but return only node ID to content ID map. + * + * @return array */ - abstract public function getSubtreeContent(int $sourceId, bool $onlyIds = false): array; + abstract public function getSubtreeNodeIdToContentIdMap(int $sourceId): array; /** * Finds draft contents created under the given parent location. diff --git a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php index 1a3b7e2538..3c09967737 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php @@ -23,7 +23,6 @@ use Ibexa\Core\Persistence\Legacy\Content\Location\Gateway; use Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter; use Ibexa\Core\Search\Legacy\Content\Common\Gateway\SortClauseConverter; -use PDO; use RuntimeException; use function time; @@ -218,25 +217,42 @@ public function loadParentLocationsDataForDraftContent(int $contentId): array return $statement->fetchAll(FetchMode::ASSOCIATIVE); } - public function getSubtreeContent(int $sourceId, bool $onlyIds = false): array + /** + * @throws \Doctrine\DBAL\Driver\Exception + * @throws \Doctrine\DBAL\Exception + */ + public function getSubtreeContent(int $sourceId): array { $query = $this->connection->createQueryBuilder(); $query - ->select($onlyIds ? 'node_id, contentobject_id, depth' : '*') + ->select('*') ->from(self::CONTENT_TREE_TABLE, 't') ->where($this->getSubtreeLimitationExpression($query, $sourceId)) ->orderBy('t.depth') ->addOrderBy('t.node_id'); - $statement = $query->executeQuery(); - $results = $statement->fetchAll($onlyIds ? (FetchMode::COLUMN | PDO::FETCH_GROUP) : FetchMode::ASSOCIATIVE); + return $query->executeQuery()->fetchAllAssociative(); + } - // array_map() is used to map all elements stored as $results[$i][0] to $results[$i] - return $onlyIds - ? array_map(static function (array $result) { - return $result[0]; - }, $results) - : $results; + /** + * @throws \Doctrine\DBAL\Exception + * @throws \Doctrine\DBAL\Driver\Exception + */ + public function getSubtreeNodeIdToContentIdMap(int $sourceId): array + { + $query = $this->connection->createQueryBuilder(); + $query + ->select('node_id', 'contentobject_id') + ->from(self::CONTENT_TREE_TABLE, 't') + ->where($this->getSubtreeLimitationExpression($query, $sourceId)) + ->orderBy('t.depth') + ->addOrderBy('t.node_id'); + $statement = $query->executeQuery(); + + return array_map( + static fn (array $row): int => $row['contentobject_id'], + $statement->fetchAllAssociativeIndexed() + ); } /** diff --git a/src/lib/Persistence/Legacy/Content/Location/Gateway/ExceptionConversion.php b/src/lib/Persistence/Legacy/Content/Location/Gateway/ExceptionConversion.php index 981fe94d2b..1e1b0d0b59 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Gateway/ExceptionConversion.php +++ b/src/lib/Persistence/Legacy/Content/Location/Gateway/ExceptionConversion.php @@ -98,11 +98,20 @@ public function loadParentLocationsDataForDraftContent(int $contentId): array } } - public function getSubtreeContent(int $sourceId, bool $onlyIds = false): array + public function getSubtreeContent(int $sourceId): array { try { - return $this->innerGateway->getSubtreeContent($sourceId, $onlyIds); - } catch (DBALException|PDOException $e) { + return $this->innerGateway->getSubtreeContent($sourceId); + } catch (DBALException | PDOException $e) { + throw DatabaseException::wrap($e); + } + } + + public function getSubtreeNodeIdToContentIdMap(int $sourceId): array + { + try { + return $this->innerGateway->getSubtreeNodeIdToContentIdMap($sourceId); + } catch (DBALException | PDOException $e) { throw DatabaseException::wrap($e); } } @@ -114,7 +123,7 @@ public function getSubtreeChildrenDraftContentIds(int $sourceId): array { try { return $this->innerGateway->getSubtreeChildrenDraftContentIds($sourceId); - } catch (PDOException $e) { + } catch (DBALException | PDOException $e) { throw DatabaseException::wrap($e); } } @@ -123,7 +132,7 @@ public function getSubtreeSize(string $path): int { try { return $this->innerGateway->getSubtreeSize($path); - } catch (DBALException|PDOException $e) { + } catch (DBALException | PDOException $e) { throw DatabaseException::wrap($e); } } diff --git a/src/lib/Persistence/Legacy/Content/Location/Handler.php b/src/lib/Persistence/Legacy/Content/Location/Handler.php index f4a9cd44d9..dc6251878f 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Handler.php +++ b/src/lib/Persistence/Legacy/Content/Location/Handler.php @@ -122,7 +122,7 @@ public function loadList(array $locationIds, array $translations = null, bool $u */ public function loadSubtreeIds($locationId) { - return $this->locationGateway->getSubtreeContent($locationId, true); + return $this->locationGateway->getSubtreeNodeIdToContentIdMap($locationId); } /** diff --git a/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php b/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php index 36a4d82d89..3809898d80 100644 --- a/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php @@ -104,15 +104,13 @@ public function testLoadLocationSubtree() { $this->locationGateway ->expects(self::once()) - ->method('getSubtreeContent') - ->with(77, true) - ->will( - self::returnValue( - [ - [77 => 100], - [78 => 101], - ] - ) + ->method('getSubtreeNodeIdToContentIdMap') + ->with(77) + ->willReturn( + [ + [77 => 100], + [78 => 101], + ] ); self::assertCount(2, $this->getLocationHandler()->loadSubtreeIds(77)); From f5acb07a8c72bc16bbd057fb8594576a4401ef1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Mon, 5 May 2025 16:02:03 +0200 Subject: [PATCH 23/26] [doctrine/dbal] Replcated ->fetch(FetchMode::ASSOCIATIVE) with fetchAssociative --- .../Legacy/Content/Location/Gateway/DoctrineDatabase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php index 3c09967737..9ce13fc198 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php @@ -76,7 +76,7 @@ public function getBasicNodeData( $query->expr()->eq('t.node_id', $query->createNamedParameter($nodeId, ParameterType::INTEGER)) ); - if ($row = $query->executeQuery()->fetch(FetchMode::ASSOCIATIVE)) { + if ($row = $query->executeQuery()->fetchAssociative()) { return $row; } From 68e56073f13d9752a3c1a86065fa8edd1312f70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Mon, 5 May 2025 19:16:56 +0200 Subject: [PATCH 24/26] Adapted Ibexa\Tests\Integration\Core\Persistence\Filter\Doctrine\FilteringQueryBuilderTest::testJoinOnce to doctrine/dbal v3 --- .../Filter/Doctrine/FilteringQueryBuilderTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/Core/Persistence/Filter/Doctrine/FilteringQueryBuilderTest.php b/tests/integration/Core/Persistence/Filter/Doctrine/FilteringQueryBuilderTest.php index ba52bbb698..238db8e822 100644 --- a/tests/integration/Core/Persistence/Filter/Doctrine/FilteringQueryBuilderTest.php +++ b/tests/integration/Core/Persistence/Filter/Doctrine/FilteringQueryBuilderTest.php @@ -9,7 +9,10 @@ namespace Ibexa\Tests\Integration\Core\Persistence\Filter\Doctrine; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; +use Doctrine\DBAL\SQL\Builder\DefaultSelectSQLBuilder; +use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder; use Ibexa\Contracts\Core\Persistence\Filter\Doctrine\FilteringQueryBuilder; use Ibexa\Core\Base\Exceptions\DatabaseException; use PHPUnit\Framework\TestCase; @@ -21,7 +24,12 @@ class FilteringQueryBuilderTest extends TestCase protected function setUp(): void { + $platform = $this->createMock(AbstractPlatform::class); + $platform->method('createSelectSQLBuilder')->willReturn(new DefaultSelectSQLBuilder($platform, null, null)); + $connectionMock = $this->createMock(Connection::class); + $connectionMock->method('getDatabasePlatform')->willReturn($platform); + $connectionMock->method('getExpressionBuilder')->willReturn( new ExpressionBuilder($connectionMock) ); From d7c6594140920d2ae3b4870b84b741f2fb02cb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Mon, 5 May 2025 19:48:21 +0200 Subject: [PATCH 25/26] Added type declaration to \Ibexa\Contracts\Core\FieldType\GatewayBasedStorage::$gateway property --- src/contracts/FieldType/GatewayBasedStorage.php | 4 +--- src/lib/FieldType/BinaryBase/BinaryBaseStorage.php | 2 +- src/lib/FieldType/Image/ImageStorage.php | 2 +- src/lib/FieldType/Keyword/KeywordStorage.php | 3 ++- src/lib/FieldType/MapLocation/MapLocationStorage.php | 3 ++- src/lib/FieldType/Url/UrlStorage.php | 2 +- src/lib/FieldType/User/UserStorage.php | 3 ++- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/contracts/FieldType/GatewayBasedStorage.php b/src/contracts/FieldType/GatewayBasedStorage.php index d0e55dab37..ec06ddfc75 100644 --- a/src/contracts/FieldType/GatewayBasedStorage.php +++ b/src/contracts/FieldType/GatewayBasedStorage.php @@ -20,11 +20,9 @@ abstract class GatewayBasedStorage implements FieldStorage /** * Field Type External Storage Gateway. * - * @var \Ibexa\Contracts\Core\FieldType\StorageGatewayInterface - * * @phpstan-var T */ - protected $gateway; + protected StorageGatewayInterface $gateway; /** * @param \Ibexa\Contracts\Core\FieldType\StorageGatewayInterface $gateway diff --git a/src/lib/FieldType/BinaryBase/BinaryBaseStorage.php b/src/lib/FieldType/BinaryBase/BinaryBaseStorage.php index 7a19ebb623..1bcc553552 100644 --- a/src/lib/FieldType/BinaryBase/BinaryBaseStorage.php +++ b/src/lib/FieldType/BinaryBase/BinaryBaseStorage.php @@ -38,7 +38,7 @@ class BinaryBaseStorage extends GatewayBasedStorage protected PathGeneratorInterface $downloadUrlGenerator; /** @var \Ibexa\Core\FieldType\BinaryBase\BinaryBaseStorage\Gateway */ - protected $gateway; + protected StorageGatewayInterface $gateway; /** @var \Ibexa\Core\FieldType\Validator\FileExtensionBlackListValidator */ protected $fileExtensionBlackListValidator; diff --git a/src/lib/FieldType/Image/ImageStorage.php b/src/lib/FieldType/Image/ImageStorage.php index 6b62d5736c..ffdd3243bf 100644 --- a/src/lib/FieldType/Image/ImageStorage.php +++ b/src/lib/FieldType/Image/ImageStorage.php @@ -32,7 +32,7 @@ class ImageStorage extends GatewayBasedStorage protected $aliasCleaner; /** @var \Ibexa\Core\FieldType\Image\ImageStorage\Gateway */ - protected $gateway; + protected StorageGatewayInterface $gateway; /** @var \Ibexa\Core\IO\FilePathNormalizerInterface */ protected $filePathNormalizer; diff --git a/src/lib/FieldType/Keyword/KeywordStorage.php b/src/lib/FieldType/Keyword/KeywordStorage.php index 6fe2a16422..61f8a366de 100644 --- a/src/lib/FieldType/Keyword/KeywordStorage.php +++ b/src/lib/FieldType/Keyword/KeywordStorage.php @@ -8,6 +8,7 @@ namespace Ibexa\Core\FieldType\Keyword; use Ibexa\Contracts\Core\FieldType\GatewayBasedStorage; +use Ibexa\Contracts\Core\FieldType\StorageGatewayInterface; use Ibexa\Contracts\Core\Persistence\Content\Field; use Ibexa\Contracts\Core\Persistence\Content\VersionInfo; @@ -21,7 +22,7 @@ class KeywordStorage extends GatewayBasedStorage { /** @var \Ibexa\Core\FieldType\Keyword\KeywordStorage\Gateway */ - protected $gateway; + protected StorageGatewayInterface $gateway; /** * @see \Ibexa\Contracts\Core\FieldType\FieldStorage diff --git a/src/lib/FieldType/MapLocation/MapLocationStorage.php b/src/lib/FieldType/MapLocation/MapLocationStorage.php index 21b957df0a..cd0457b59a 100644 --- a/src/lib/FieldType/MapLocation/MapLocationStorage.php +++ b/src/lib/FieldType/MapLocation/MapLocationStorage.php @@ -8,6 +8,7 @@ namespace Ibexa\Core\FieldType\MapLocation; use Ibexa\Contracts\Core\FieldType\GatewayBasedStorage; +use Ibexa\Contracts\Core\FieldType\StorageGatewayInterface; use Ibexa\Contracts\Core\Persistence\Content\Field; use Ibexa\Contracts\Core\Persistence\Content\VersionInfo; @@ -17,7 +18,7 @@ class MapLocationStorage extends GatewayBasedStorage { /** @var \Ibexa\Core\FieldType\MapLocation\MapLocationStorage\Gateway */ - protected $gateway; + protected StorageGatewayInterface $gateway; public function storeFieldData(VersionInfo $versionInfo, Field $field) { diff --git a/src/lib/FieldType/Url/UrlStorage.php b/src/lib/FieldType/Url/UrlStorage.php index bcc76eb135..1458945d76 100644 --- a/src/lib/FieldType/Url/UrlStorage.php +++ b/src/lib/FieldType/Url/UrlStorage.php @@ -22,7 +22,7 @@ class UrlStorage extends GatewayBasedStorage protected $logger; /** @var \Ibexa\Core\FieldType\Url\UrlStorage\Gateway */ - protected $gateway; + protected StorageGatewayInterface $gateway; /** * Construct from gateways. diff --git a/src/lib/FieldType/User/UserStorage.php b/src/lib/FieldType/User/UserStorage.php index b9535d6595..3ff5f025c5 100644 --- a/src/lib/FieldType/User/UserStorage.php +++ b/src/lib/FieldType/User/UserStorage.php @@ -8,6 +8,7 @@ namespace Ibexa\Core\FieldType\User; use Ibexa\Contracts\Core\FieldType\GatewayBasedStorage; +use Ibexa\Contracts\Core\FieldType\StorageGatewayInterface; use Ibexa\Contracts\Core\Persistence\Content\Field; use Ibexa\Contracts\Core\Persistence\Content\VersionInfo; @@ -33,7 +34,7 @@ class UserStorage extends GatewayBasedStorage * * @var \Ibexa\Core\FieldType\User\UserStorage\Gateway */ - protected $gateway; + protected StorageGatewayInterface $gateway; public function storeFieldData(VersionInfo $versionInfo, Field $field) { From 9f571e07ce1d4a96ef239d0916b9b62b5d00aa37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Mon, 5 May 2025 20:22:59 +0200 Subject: [PATCH 26/26] Added type declaration to Ibexa\Core\Search\Common\Indexer properties --- src/lib/Search/Common/Indexer.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib/Search/Common/Indexer.php b/src/lib/Search/Common/Indexer.php index 14233d4fa9..600041d310 100644 --- a/src/lib/Search/Common/Indexer.php +++ b/src/lib/Search/Common/Indexer.php @@ -8,7 +8,6 @@ namespace Ibexa\Core\Search\Common; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Result; use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; use Ibexa\Contracts\Core\Persistence\Handler as PersistenceHandler; @@ -22,17 +21,13 @@ */ abstract class Indexer { - /** @var \Psr\Log\LoggerInterface */ - protected $logger; + protected LoggerInterface $logger; - /** @var \Ibexa\Contracts\Core\Persistence\Handler */ - protected $persistenceHandler; + protected PersistenceHandler $persistenceHandler; - /** @var \Doctrine\DBAL\Connection */ - protected $connection; + protected Connection $connection; - /** @var \Ibexa\Contracts\Core\Search\Handler */ - protected $searchHandler; + protected SearchHandler $searchHandler; public function __construct( LoggerInterface $logger,