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

API Signals are not transaction safe

    XMLWordPrintable

Details

    • Castor Core S3

    Description

      When deleting locations via Public API they are not removed from Solr if a transaction is used.

      Steps to reproduce:

      Start from an eZ Publish 5.2 site, with all updates applied, and eZ Find installed.

      1. Create a new Bundle and create a command with the following code:

      <?php
      namespace EzSystems\TestBundle\Command;
      
      use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand,
      Symfony\Component\Console\Input\InputInterface,
      Symfony\Component\Console\Output\OutputInterface,
      Symfony\Component\Console\Input\InputArgument,
      Symfony\Component\Console\Input\InputOption;
       
      class RemoveLocationCommand extends \Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
      {
          /**
           * Configures the command
           */
          protected function configure()
          {
              $this->setName( 'location:remove' )->setDefinition(
                  array(
                      new InputArgument( 'locationID', InputArgument::REQUIRED, 'Location ID' ),
                  )
              );
          }
       
          protected function execute( InputInterface $input, OutputInterface $output )
          {
              /** @var $repository \eZ\Publish\API\Repository\Repository */
              $repository = $this->getContainer()->get( 'ezpublish.api.repository' );
              $repository->beginTransaction();
              $locationService = $repository->getLocationService();
              $userService = $repository->getUserService();
              $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) );
              $locationID = $input->getArgument( 'locationID' );
              $location = $locationService->loadLocation( $locationID );
              $locationService->deleteLocation( $location );
              $repository->commit();
          }
      }
      

      2. Create a content object with a single location, from the backend
      3. Remove the location running php ezpublish/console location:remove <LOCATION_ID>
      4. On Solr interface search for your object

      The object will be gone in the database, but still exist in Solr.

      If we don't use a transaction for this operation the object will be removed completely, both from database and Solr, as expected.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ricardo.correia-obsolete@ez.no Ricardo Correia (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 5 hours, 30 minutes Remaining Estimate - 2 hours, 30 minutes
                2h 30m
                Logged:
                Time Spent - 5 hours, 30 minutes Remaining Estimate - 2 hours, 30 minutes
                5h 30m