Details
-
Bug
-
Resolution: Fixed
-
Medium
-
5.2, 5.3, 5.4-dev
-
None
-
eZ Publish 5.2 Platform
eZ Find LS 5.2.0
-
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.