From 3d412b684957a5ec12ba2bdfa81d0d25d45527f4 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 8 May 2024 13:46:10 +0200 Subject: [PATCH] IBX-6833: Applied review remarks --- eZ/Publish/Core/Repository/ContentService.php | 4 ++-- .../CopyTranslationsFromPublishedVersionTest.php | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/eZ/Publish/Core/Repository/ContentService.php b/eZ/Publish/Core/Repository/ContentService.php index 797fb373ea..370bba6c90 100644 --- a/eZ/Publish/Core/Repository/ContentService.php +++ b/eZ/Publish/Core/Repository/ContentService.php @@ -1295,7 +1295,7 @@ protected function internalUpdateContent( APIVersionInfo $versionInfo, APIContentUpdateStruct $contentUpdateStruct, ?array $fieldIdentifiersToValidate = null, - bool $doAddEmpty = false + bool $copyEmptyField = false ): Content { $contentUpdateStruct = clone $contentUpdateStruct; @@ -1386,7 +1386,7 @@ protected function internalUpdateContent( ); $fieldValues[$fieldDefinition->identifier][$languageCode] = $fieldValue; - if ($isRetained || $isCopied || ($isLanguageNew && $isEmpty && !$doAddEmpty) || $isProcessed) { + if ($isRetained || $isCopied || ($isLanguageNew && $isEmpty && !$copyEmptyField) || $isProcessed) { continue; } diff --git a/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php b/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php index f95952d68e..8ba05c9867 100644 --- a/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php +++ b/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php @@ -10,6 +10,7 @@ use DateTime; use eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionCreateStruct; +use eZ\Publish\Core\FieldType\TextLine; use eZ\Publish\Core\Repository\Values\Content\ContentUpdateStruct; use Ibexa\Tests\Integration\Core\RepositoryTestCase; @@ -67,11 +68,13 @@ public function testCopyTranslationsFromPublishedVersionCopiesEmptyValues(): voi $usContent = $contentService->updateContent($usDraft->getVersionInfo(), $contentUpdateStruct); $publishedUsContent = $contentService->publishVersion($usContent->getVersionInfo(), [self::US_LANGUAGE_CODE]); - $gerFieldValueInUsContent = $publishedUsContent->getField('title', self::GER_LANGUAGE_CODE) - ->getValue() - ->text; + $usFieldValueInUsContent = $publishedUsContent->getField('title', self::US_LANGUAGE_CODE)->getValue(); + self::assertInstanceOf(TextLine\Value::class, $usFieldValueInUsContent); + self::assertSame('', $usFieldValueInUsContent->text); - self::assertSame('', $gerFieldValueInUsContent); + $gerFieldValueInUsContent = $publishedUsContent->getField('title', self::GER_LANGUAGE_CODE)->getValue(); + self::assertInstanceOf(TextLine\Value::class, $gerFieldValueInUsContent); + self::assertSame('', $gerFieldValueInUsContent->text); } private function createContentType(): void