From c2257021c67b12b1d36630b7ee4da2f27088d7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20D=C4=99bi=C5=84ski?= <58430570+mateuszdebinski@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:12:35 +0200 Subject: [PATCH] IBX-6484: Fixed Content Handler `loadVersionInfoList` database error For more details see https://issues.ibexa.co/browse/IBX-6484 and https://github.com/ezsystems/ezplatform-kernel/pull/384 Key changes: * Added check if `$row` is empty to prevent a database error in persistence Content Handler `loadVersionInfoList`. --- .../Core/Persistence/Legacy/Content/Handler.php | 5 +++++ .../ContentService/LoadVersionInfoTest.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/Handler.php index 22abbb9db9..0fb6e39a2b 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Handler.php @@ -911,6 +911,11 @@ static function ($lang) use ($languageCode) { public function loadVersionInfoList(array $contentIds): array { $rows = $this->contentGateway->loadVersionInfoList($contentIds); + + if (empty($rows)) { + return []; + } + $mappedRows = array_map( static function (array $row): array { return [ diff --git a/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php b/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php index 7938367526..5c8a7b5771 100644 --- a/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php +++ b/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php @@ -42,4 +42,18 @@ public function testLoadVersionInfoListByContentInfo(): void self::assertEquals($loadedVersionInfo, $versionInfo); } } + + public function testLoadVersionInfoListByContentInfoForTopLevelNode(): void + { + $contentService = self::getContentService(); + $locationService = self::getLocationService(); + + $location = $locationService->loadLocation(1); + + $versionInfoList = $contentService->loadVersionInfoListByContentInfo( + [$location->getContentInfo()] + ); + + self::assertCount(0, $versionInfoList); + } }