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

    XMLWordPrintable

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');
        

      Attachments

        Activity

          People

            Unassigned Unassigned
            jacek.foremski-obsolete@ez.no 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