Details
-
Improvement
-
Resolution: Fixed
-
High
-
1.11.0
-
None
Description
After changing the main translation of the Content Object, there can exist some versions of this Content Object that have only one translation, different from the main translation. Trying to delete this translation results in the following error:
Argument '$languageCode' has a bad state: Specified translation is the only one Content Object Version has
The deletion of the translation that is no longer the main translation should be possible.
Steps to reproduce
- Create new eZ Platform installation.
- Add the second language (for example "pol-PL") in the Platform UI as well as in your ezplatform.yml.
- Create new Content Object in "pol-PL". It should now have version 1 in the "pol-PL" language.
- Translate it to the second language. It should now have version 2 in the "eng-GB" and "pol-PL" languages.
- Create and run the command that changes the main language of the Content Object to "eng-GB" and removes the "pol-PL" translation. Running it results in the error above. Snippet for that command (change "52" to your Content Id):
$repository = $this->getContainer()->get('ezpublish.api.repository'); $userService = $repository->getUserService(); $permissionResolver = $repository->getPermissionResolver(); $user = $userService->loadUserByLogin('admin'); $permissionResolver->setCurrentUserReference($user); $contentService = $repository->getContentService(); $metaDataUpdateStruct = $contentService->newContentMetadataUpdateStruct(); $metaDataUpdateStruct->mainLanguageCode = 'eng-GB'; $content = $contentService->loadContent(52); $content = $contentService->updateContentMetadata($content->contentInfo, $metaDataUpdateStruct); $contentService->removeTranslation($content->contentInfo, 'pol-PL');
Attachments
Issue Links
- relates to
-
EZP-27417 As a Developer I want API to allow removal of the translation from all content object versions
- Closed