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

Copy calls post_publish workflow before content is published

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: High High
    • Resolution: Invalid
    • Affects Version/s: 5.3.11
    • Fix Version/s: Customer request
    • Component/s: Legacy > Workflows
    • Labels:
      None

      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)"} []
      

        Activity

        Hide
        André Rømcke added a comment - - edited

        This is not a bug but an enhancement, we have never promised callbacks triggering database calls between kernels to work within transactions, effectively making it unsupported to run platform stack api calls form whiten things like workflow events which are almost always within transaction. It was never made for that, so we should stop risking breaking other peoples code for change requests on a stable version.

        Prefer to use ezpEvent as integration point, these are typically outside the transactions.

        Show
        André Rømcke added a comment - - edited This is not a bug but an enhancement, we have never promised callbacks triggering database calls between kernels to work within transactions, effectively making it unsupported to run platform stack api calls form whiten things like workflow events which are almost always within transaction. It was never made for that, so we should stop risking breaking other peoples code for change requests on a stable version. Prefer to use ezpEvent as integration point, these are typically outside the transactions.
        Hide
        André Rømcke added a comment -

        Closing as invalid, content is being published but is within a transaction.
        Calls between kernels involving database within transaction are not supported.

        For integration prefer use of ezpEvent which is always trying to be outside transaction, or if you need to load data within legacy workflow, use legacy kernel for it.

        Show
        André Rømcke added a comment - Closing as invalid, content is being published but is within a transaction. Calls between kernels involving database within transaction are not supported. For integration prefer use of ezpEvent which is always trying to be outside transaction, or if you need to load data within legacy workflow, use legacy kernel for it.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: