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

Can't publish/save content with missing object in "Object relations" field

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: High High
    • Customer request
    • 5.4.10
    • Field types
    • None

    Description

      When trying to save/publish a Content Object that has ezobjectrelationlist Field Type with the related object that no longer exists (because it was moved to trash) using Public PHP API the following error is shown:

      [RuntimeException]
        Missing relation-item external data property: ezcontentobject_tree_node_id
      

      This issue is already fixed in eZ Platform: EZP-26342. Probably the backport to 5.4 is enough to fix it.

      Steps to reproduce

      1. Create new eZ Publish installation.
      2. Create new article named "Test Article".
      3. Create a new Content Type named "Multiple Relations Content Type" with two Content Fields:
        • ezstring named "Title".
        • ezobjectrelationlist named "Relations".
      4. Create new Content Object with "Multiple Relations Content Type" Content Type. In the "Title" field type "Multiple Relations Test" and in the "Relations" field select "Test Article".
      5. Move "Test Article" to trash
      6. Add the following command to your App Bundle:
        <?php
        
        namespace AppBundle\Command;
        
        use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
        use Symfony\Component\Console\Input\InputInterface;
        use Symfony\Component\Console\Output\OutputInterface;
        
        class TestCommand extends ContainerAwareCommand
        {
            /**
             * {@inheritdoc}
             */
            protected function configure()
            {
                $this
                    ->setName('app:test_command');
            }
        
            /**
             * {@inheritdoc}
             */
            protected function execute(InputInterface $input, OutputInterface $output)
            {
                $repository = $this->getContainer()->get('ezpublish.api.repository');
        
                $userService = $repository->getUserService();
                $user = $userService->loadUserByLogin('admin');
                $repository->setCurrentUser($user);
        
                $contentService = $repository->getContentService();
                $content = $contentService->loadContent(64);
                $contentUpdateStruct = $contentService->newContentUpdateStruct();
                $contentUpdateStruct->setField('title', 'Multiple Relations Test 2');
        
                $contentDraft = $contentService->createContentDraft($content->contentInfo);
        
                $contentDraft = $contentService->updateContent($contentDraft->versionInfo, $contentUpdateStruct);
                $content = $contentService->publishVersion($contentDraft->versionInfo);
        
                var_dump($content);
            }
        }
        
      7. Run the command by entering the following in the console:
        php ezpublish/console app:test_command
        
      8. You will be presented with the error described above.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jacek.foremski-obsolete@ez.no Jacek Foremski (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: