Skip to content
Merged
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<<SQL
INSERT INTO {$contentLinkTable} (
INSERT INTO $contentLinkTable (
contentclassattribute_id,
from_contentobject_id,
from_contentobject_version,
Expand Down Expand Up @@ -2059,7 +2059,7 @@ private function deleteTranslationFromContentVersions(
->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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
]
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1417,11 +1417,11 @@ private function cleanupClassAttributeTable(): void
$contentTypeAttrTable = Gateway::FIELD_DEFINITION_TABLE;
$contentTypeTable = Gateway::CONTENT_TYPE_TABLE;
$sql = <<<SQL
DELETE FROM {$contentTypeAttrTable}
DELETE FROM $contentTypeAttrTable
WHERE NOT EXISTS (
SELECT 1 FROM {$contentTypeTable}
WHERE {$contentTypeTable}.id = {$contentTypeAttrTable}.contentclass_id
AND {$contentTypeTable}.version = {$contentTypeAttrTable}.version
SELECT 1 FROM $contentTypeTable
WHERE $contentTypeTable.id = $contentTypeAttrTable.contentclass_id
AND $contentTypeTable.version = $contentTypeAttrTable.version
)
SQL;
$this->connection->executeStatement($sql);
Expand All @@ -1435,11 +1435,11 @@ private function cleanupClassAttributeMLTable(): void
$contentTypeAttrMlTable = Gateway::MULTILINGUAL_FIELD_DEFINITION_TABLE;
$contentTypeAttrTable = Gateway::FIELD_DEFINITION_TABLE;
$sql = <<<SQL
DELETE FROM {$contentTypeAttrMlTable}
DELETE FROM $contentTypeAttrMlTable
WHERE NOT EXISTS (
SELECT 1 FROM {$contentTypeAttrTable}
WHERE {$contentTypeAttrTable}.id = {$contentTypeAttrMlTable}.contentclass_attribute_id
AND {$contentTypeAttrTable}.version = {$contentTypeAttrMlTable}.version
SELECT 1 FROM $contentTypeAttrTable
WHERE $contentTypeAttrTable.id = $contentTypeAttrMlTable.contentclass_attribute_id
AND $contentTypeAttrTable.version = $contentTypeAttrMlTable.version
)
SQL;
$this->connection->executeStatement($sql);
Expand All @@ -1453,11 +1453,11 @@ private function cleanupClassGroupTable(): void
$contentTypeGroupAssignmentTable = Gateway::CONTENT_TYPE_TO_GROUP_ASSIGNMENT_TABLE;
$contentTypeTable = Gateway::CONTENT_TYPE_TABLE;
$sql = <<<SQL
DELETE FROM {$contentTypeGroupAssignmentTable}
DELETE FROM $contentTypeGroupAssignmentTable
WHERE NOT EXISTS (
SELECT 1 FROM {$contentTypeTable}
WHERE {$contentTypeTable}.id = {$contentTypeGroupAssignmentTable}.contentclass_id
AND {$contentTypeTable}.version = {$contentTypeGroupAssignmentTable}.contentclass_version
SELECT 1 FROM $contentTypeTable
WHERE $contentTypeTable.id = $contentTypeGroupAssignmentTable.contentclass_id
AND $contentTypeTable.version = $contentTypeGroupAssignmentTable.contentclass_version
)
SQL;
$this->connection->executeStatement($sql);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -164,12 +163,20 @@ protected function getGateway(): DoctrineDatabase
);
}

/**
* @return array<string,mixed>
*
* @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 : [];
}
Expand Down
Loading