diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b50db72d19..c105d92fdf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -60432,12 +60432,6 @@ parameters: count: 1 path: tests/lib/Persistence/Legacy/HandlerTest.php - - - message: '#^Method Ibexa\\Tests\\Core\\Persistence\\Legacy\\Notification\\Gateway\\DoctrineDatabaseTest\:\:loadNotification\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabaseTest.php - - message: '#^Method Ibexa\\Tests\\Core\\Persistence\\Legacy\\Notification\\Gateway\\DoctrineDatabaseTest\:\:testCountUserNotifications\(\) has no return type specified\.$#' identifier: missingType.return diff --git a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index 06ffc3fc12..01e53890c3 100644 --- a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -1872,7 +1872,7 @@ public function copyRelations( // Given we can retain all columns, we just create copies with new `from_contentobject_id` using INSERT INTO SELECT $contentLinkTable = Gateway::CONTENT_RELATION_TABLE; $insertQuery = <<set( 'initial_language_id', 'CASE WHEN initial_language_id = :languageId ' . - "THEN (SELECT initial_language_id AS main_language_id FROM {$contentTable} c WHERE c.id = :contentId) " . + "THEN (SELECT initial_language_id AS main_language_id FROM $contentTable c WHERE c.id = :contentId) " . 'ELSE initial_language_id END' ) ->where('contentobject_id = :contentId') diff --git a/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php index 97d4fa2767..0e96dad9e4 100644 --- a/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabase.php @@ -161,8 +161,8 @@ public function insertObjectState(ObjectState $objectState, int $groupId): void { $maxPriority = $this->getMaxPriorityForObjectStatesInGroup($groupId); - $objectState->priority = $maxPriority === null ? 0 : (int)$maxPriority + 1; - $objectState->groupId = (int)$groupId; + $objectState->priority = $maxPriority === null ? 0 : $maxPriority + 1; + $objectState->groupId = $groupId; $query = $this->connection->createQueryBuilder(); $query @@ -208,7 +208,13 @@ public function insertObjectState(ObjectState $objectState, int $groupId): void if ($maxPriority === null) { $this->connection->executeStatement( 'INSERT INTO ' . Gateway::OBJECT_STATE_LINK_TABLE . ' (contentobject_id, contentobject_state_id) ' . - "SELECT id, {$objectState->id} FROM ibexa_content" + 'SELECT id, :object_state_id FROM ibexa_content', + [ + 'object_state_id' => $objectState->id, + ], + [ + 'object_state_id' => ParameterType::INTEGER, + ] ); } } diff --git a/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php index e799e68e29..eb4f0c1b1f 100644 --- a/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php @@ -1117,7 +1117,7 @@ public function deleteFieldDefinitionsForType(int $typeId, int $status): void ->select('f_def.id as content_type_field_definition_id') ->from(self::FIELD_DEFINITION_TABLE, 'f_def') ->where('f_def.contentclass_id = :content_type_id') - ->andWhere("f_def.id = {$ctMlTable}.contentclass_attribute_id"); + ->andWhere("f_def.id = $ctMlTable.contentclass_attribute_id"); $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery @@ -1305,7 +1305,7 @@ public function publishTypeAndFields(int $typeId, int $sourceStatus, int $target ->select('f_def.id as content_type_field_definition_id') ->from(self::FIELD_DEFINITION_TABLE, 'f_def') ->where('f_def.contentclass_id = :type_id') - ->andWhere("f_def.id = {$ctMlTable}.contentclass_attribute_id"); + ->andWhere("f_def.id = $ctMlTable.contentclass_attribute_id"); $mlDataPublishQuery = $this->connection->createQueryBuilder(); $mlDataPublishQuery @@ -1417,11 +1417,11 @@ private function cleanupClassAttributeTable(): void $contentTypeAttrTable = Gateway::FIELD_DEFINITION_TABLE; $contentTypeTable = Gateway::CONTENT_TYPE_TABLE; $sql = <<connection->executeStatement($sql); @@ -1435,11 +1435,11 @@ private function cleanupClassAttributeMLTable(): void $contentTypeAttrMlTable = Gateway::MULTILINGUAL_FIELD_DEFINITION_TABLE; $contentTypeAttrTable = Gateway::FIELD_DEFINITION_TABLE; $sql = <<connection->executeStatement($sql); @@ -1453,11 +1453,11 @@ private function cleanupClassGroupTable(): void $contentTypeGroupAssignmentTable = Gateway::CONTENT_TYPE_TO_GROUP_ASSIGNMENT_TABLE; $contentTypeTable = Gateway::CONTENT_TYPE_TABLE; $sql = <<connection->executeStatement($sql); @@ -1471,11 +1471,11 @@ private function cleanupClassNameTable(): void $contentTypeNameTable = Gateway::CONTENT_TYPE_NAME_TABLE; $contentTypeTable = Gateway::CONTENT_TYPE_TABLE; $sql = <<< SQL - DELETE FROM {$contentTypeNameTable} + DELETE FROM $contentTypeNameTable WHERE NOT EXISTS ( - SELECT 1 FROM {$contentTypeTable} - WHERE {$contentTypeTable}.id = {$contentTypeNameTable}.contentclass_id - AND {$contentTypeTable}.version = {$contentTypeNameTable}.contentclass_version + SELECT 1 FROM $contentTypeTable + WHERE $contentTypeTable.id = $contentTypeNameTable.contentclass_id + AND $contentTypeTable.version = $contentTypeNameTable.contentclass_version ) SQL; $this->connection->executeStatement($sql); diff --git a/tests/integration/Core/BinaryBase/BinaryBaseStorage/BinaryBaseStorageGatewayTest.php b/tests/integration/Core/BinaryBase/BinaryBaseStorage/BinaryBaseStorageGatewayTest.php index 4b9e9e3f5d..43746ee0ad 100644 --- a/tests/integration/Core/BinaryBase/BinaryBaseStorage/BinaryBaseStorageGatewayTest.php +++ b/tests/integration/Core/BinaryBase/BinaryBaseStorage/BinaryBaseStorageGatewayTest.php @@ -28,7 +28,7 @@ protected function setUp(): void parent::setUp(); $importer = new FixtureImporter($this->getDatabaseConnection()); - $importer->import(new YamlFixture(__DIR__ . '/_fixtures/ezbinaryfile.yaml')); + $importer->import(new YamlFixture(__DIR__ . '/_fixtures/ibexa_binary_file.yaml')); } protected function getGateway(): BinaryBaseStorageGateway diff --git a/tests/integration/Core/BinaryBase/BinaryBaseStorage/_fixtures/ezbinaryfile.yaml b/tests/integration/Core/BinaryBase/BinaryBaseStorage/_fixtures/ibexa_binary_file.yaml similarity index 100% rename from tests/integration/Core/BinaryBase/BinaryBaseStorage/_fixtures/ezbinaryfile.yaml rename to tests/integration/Core/BinaryBase/BinaryBaseStorage/_fixtures/ibexa_binary_file.yaml diff --git a/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php index cf22ba6cf4..933fcd5973 100644 --- a/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php @@ -14,7 +14,7 @@ use Ibexa\Tests\Core\Persistence\Legacy\TestCase; /** - * @covers \DoctrineDatabase::insertBookmark + * @covers \Ibexa\Core\Persistence\Legacy\Bookmark\Gateway */ class DoctrineDatabaseTest extends TestCase { @@ -149,7 +149,7 @@ protected function getGateway(): Gateway private function loadBookmark(int $id): array { $qb = $this->connection->createQueryBuilder(); - $qb->select('*') + $qb->select('id', 'name', 'node_id', 'user_id') ->from(DoctrineDatabase::TABLE_BOOKMARKS) ->where('id = :id') ->setParameter('id', $id); diff --git a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php index 6b33e93290..437550009b 100644 --- a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php @@ -24,7 +24,7 @@ use Ibexa\Tests\Core\Persistence\Legacy\Content\LanguageAwareTestCase; /** - * @covers \Ibexa\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::insertContentObject + * @covers \Ibexa\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase */ class DoctrineDatabaseTest extends LanguageAwareTestCase { diff --git a/tests/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabaseTest.php index 20225ca5b4..ac9d3c1fac 100644 --- a/tests/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabaseTest.php @@ -8,7 +8,6 @@ namespace Ibexa\Tests\Core\Persistence\Legacy\Notification\Gateway; -use Doctrine\DBAL\FetchMode; use Ibexa\Contracts\Core\Persistence\Notification\CreateStruct; use Ibexa\Contracts\Core\Persistence\Notification\Notification; use Ibexa\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase; @@ -164,12 +163,20 @@ protected function getGateway(): DoctrineDatabase ); } + /** + * @return array + * + * @throws \Doctrine\DBAL\Exception + */ private function loadNotification(int $id): array { $table = DoctrineDatabase::TABLE_NOTIFICATION; $data = $this->connection - ->executeQuery("SELECT * FROM {$table} WHERE id = :id", ['id' => $id]) - ->fetch(FetchMode::ASSOCIATIVE); + ->executeQuery( + "SELECT id, owner_id, is_pending, type, created, data FROM $table WHERE id = :id", + ['id' => $id] + ) + ->fetchAssociative(); return is_array($data) ? $data : []; }