Details
-
Bug
-
Resolution: Done
-
Medium
-
3.3.6
-
None
Description
When we try to use Function deleteLocation then throw errors and not correctly clear SOLR - still visible this content but it's not accessibly
Steps to reproduce
- Install clean Ibexa DXP 3.3
- Create article
- create Command and run php bin/console app:delete-location articleLocationId
<?php namespace App\Command; use Exception; use eZ\Publish\API\Repository\Exceptions\NotFoundException; use eZ\Publish\API\Repository\LocationService; use eZ\Publish\API\Repository\Repository; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; class DeleteLocationCommand extends Command { protected static $defaultName = 'app:delete-location'; protected static $defaultDescription = 'Command to delete a location by location id'; /** * @var \eZ\Publish\API\Repository\LocationService */ private $locationService; /** * @var Repository */ private $repository; public function __construct( LocationService $locationService, Repository $repository ) { parent::__construct(); $this->locationService = $locationService; $this->repository = $repository; } protected function configure(): void { $this ->addArgument('locationId', InputArgument::REQUIRED, 'Location ID to delete') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $locationId = $input->getArgument('locationId'); $result = $this->repository->sudo(function () use ($locationId, $io) { try { $location = $this->locationService->loadLocation($locationId); } catch (NotFoundException $e) { $io->error($e->getMessage()); return Command::FAILURE; } $this->repository->beginTransaction(); try { $this->locationService->deleteLocation($location); $this->repository->commit(); } catch (Exception $e) { $this->repository->rollback(); $io->error($e->getMessage()); $io->error($e->getFile() . '-- #' . $e->getLine()); $io->comment($e->getTraceAsString()); return Command::FAILURE; } return Command::SUCCESS; }); return $result; } }
Result
Expected result
Location delete without any errors