Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-27842

Allow to remove the translation of the Content Object when this translation is the only one the Content Object Version has

    Details

      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

      1. Create new eZ Platform installation.
      2. Add the second language (for example "pol-PL") in the Platform UI as well as in your ezplatform.yml.
      3. Create new Content Object in "pol-PL". It should now have version 1 in the "pol-PL" language.
      4. Translate it to the second language. It should now have version 2 in the "eng-GB" and "pol-PL" languages.
      5. 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');
        

        Issue Links

          Activity

          Hide
          Andrzej Longosz added a comment -

          PR https://github.com/ezsystems/ezpublish-kernel/pull/2080
          implementing:

          • Command to remove translation by Content Object Id and language code.
          • Improved error message specified in the issue description, so it is more clear that error is related to specific Version number.
          Show
          Andrzej Longosz added a comment - PR https://github.com/ezsystems/ezpublish-kernel/pull/2080 implementing: Command to remove translation by Content Object Id and language code. Improved error message specified in the issue description, so it is more clear that error is related to specific Version number.
          Show
          André Rømcke added a comment - Merged: https://github.com/ezsystems/ezpublish-kernel/commit/d0f50d7a50a9cbdd633eec31b9e42c0cd29ea9a9
          Hide
          Paulo Nunes (Inactive) added a comment -

          QA Approved

          Show
          Paulo Nunes (Inactive) added a comment - QA Approved

            People

            • Assignee:
              Unassigned
              Reporter:
              Jacek Foremski (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 4 hours
                1d 4h