From 751c9d4866ab04fc1e26d8868a49083194b7f40e Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 13 May 2021 18:01:46 +0200 Subject: [PATCH 1/2] EZP-32361: Fixed Subtree copying when child invisible --- .../Repository/Tests/LocationServiceTest.php | 41 +++++++++++++++++++ .../Legacy/Content/Location/Handler.php | 5 ++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php index 8b321dc18b5..b63e4da8b17 100644 --- a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php @@ -2520,6 +2520,47 @@ public function testCopySubtreeIncrementsChildCountOfNewParent() $this->assertEquals($childCountBefore + 1, $childCountAfter); } + /** + * @covers \eZ\Publish\API\Repository\LocationService::copySubtree() + */ + public function testCopySubtreeWithInvisibleChild(): void + { + $repository = $this->getRepository(); + $locationService = $repository->getLocationService(); + + // Hide child Location + $locationService->hideLocation($locationService->loadLocation($this->generateId('location', 53))); + + $locationToCopy = $locationService->loadLocation($this->generateId('location', 43)); + + $expected = $this->loadSubtreeProperties($locationToCopy); + + $mediaLocationId = $this->generateId('location', 43); + $demoDesignLocationId = $this->generateId('location', 56); + $locationService = $repository->getLocationService(); + + $locationToCopy = $locationService->loadLocation($mediaLocationId); + + $newParentLocation = $locationService->loadLocation($demoDesignLocationId); + + $copiedLocation = $locationService->copySubtree( + $locationToCopy, + $newParentLocation + ); + + $this->refreshSearch($repository); + + // Load Subtree properties after copy + $actual = $this->loadSubtreeProperties($copiedLocation); + + self::assertEquals(count($expected), count($actual)); + + foreach ($actual as $key => $properties) { + self::assertEquals($expected[$key]['hidden'], $properties['hidden']); + self::assertEquals($expected[$key]['invisible'], $properties['invisible']); + } + } + /** * Test for the copySubtree() method. * diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php index 6c2fffd06f3..9e7d18f4ece 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php @@ -287,7 +287,10 @@ public function copySubtree($sourceId, $destinationParentId, $newOwnerId = null) $createStruct->contentId = $contentMap[$child['contentobject_id']]; $parentData = $locationMap[$child['parent_node_id']]; $createStruct->parentId = $parentData['id']; - $createStruct->invisible = $createStruct->hidden || $parentData['hidden'] || $parentData['invisible']; + $createStruct->invisible = $createStruct->invisible + || $createStruct->hidden + || $parentData['hidden'] + || $parentData['invisible']; $pathString = explode('/', $child['path_identification_string']); $pathString = end($pathString); $createStruct->pathIdentificationString = strlen($pathString) > 0 From 0f32844e641d5a9bb0f66da07ee64b1969daf6b4 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 20 May 2021 19:24:15 +0200 Subject: [PATCH 2/2] EZP-32361: Fixed integration test for Solr --- eZ/Publish/API/Repository/Tests/LocationServiceTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php index b63e4da8b17..b5f898d7742 100644 --- a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php @@ -2531,6 +2531,8 @@ public function testCopySubtreeWithInvisibleChild(): void // Hide child Location $locationService->hideLocation($locationService->loadLocation($this->generateId('location', 53))); + $this->refreshSearch($repository); + $locationToCopy = $locationService->loadLocation($this->generateId('location', 43)); $expected = $this->loadSubtreeProperties($locationToCopy);