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

Copy calls post_publish workflow before content is published

    XMLWordPrintable

Details

    Description

      Steps to reproduce:

      1. Prepare a test eZ Publish 5.3, fully updated;

      Ref: https://doc.ez.no/display/EZP/5.3.x+Update+Instructions

      2. Implement a content/post_publish workflow, in a customer legacy extension:

      /**
       * Custom Workflow event to add default flow blocks after save
       */
      class DefaultBlocksType extends eZWorkflowEventType
      {
          const WORKFLOW_TYPE_STRING = 'defaultblocks';
      
          /**
           * DefaultBlocksType constructor.
           */
          public function __construct()
          {
              // Set descriptive name
              $this->eZWorkflowEventType(DefaultBlocksType::WORKFLOW_TYPE_STRING, 'Default Flow Blocks');
      
              $this->setTriggerTypes(array('content' => array('publish' => array('after'))));
          }
      
          /**
           * Execute workflow
           *
           * @inheritdoc
           */
          public function execute($process, $event)
          {
              // Extract parameters
              $parameters = $process->attribute('parameter_list');
              $contentId = $parameters['object_id'];
      
              // Fetch container to access symfony services
              $container = ezpKernel::instance()->getServiceContainer();
              $content = $container->get('ezpublish.api.repository')->getContentService()->loadContent($contentId);
      
              return eZWorkflowType::STATUS_ACCEPTED;
          }
      }
      
      // Register workflow event
      eZWorkflowEventType::registerEventType(DefaultBlocksType::WORKFLOW_TYPE_STRING, 'DefaultBlocksType');
      

      Note: see attached "mytestworkflow" extension for reference.

      3. Enable the extension and regenerate autoloads;
      4. On the admin interface, create a new workflow based on the newly created custom workflow;
      5. Add the new workflow to the content|publish|after trigger;
      6. Copy an existing content in the admin interface. It fails with a "500 Internal Server Error" error.

      Symfony log:

      [2016-12-08 18:04:46] request.CRITICAL: Uncaught PHP Exception eZ\Publish\Core\Base\Exceptions\NotFoundException: "Could not find 'Content' with identifier 'array (   'id' => 120,   'languages' => NULL,   'versionNo' => NULL, )'" at /var/www/53ezdemo.com/vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/Repository/ContentService.php line 393 {"exception":"[object] (eZ\\Publish\\Core\\Base\\Exceptions\\NotFoundException(code: 404): Could not find 'Content' with identifier 'array (\n  'id' => 120,\n  'languages' => NULL,\n  'versionNo' => NULL,\n)' at /var/www/53ezdemo.com/vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/Repository/ContentService.php:393, eZ\\Publish\\Core\\Base\\Exceptions\\NotFoundException(code: 404): Could not find 'content' with identifier 'id: 120' at /var/www/53ezdemo.com/vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php:860)"} []
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            nuno.oliveira-obsolete@ez.no Nuno Oliveira (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: