Skip to content

Commit e4367c7

Browse files
authored
[BUGFIX] Always catch StopRecordOperationException (#68)
* [BUGFIX] Always catch StopRecordOperationException When calling `interest:create --update` on a remote ID that exists or `interest:update --create` on a remote ID that doesn't exist, `StopRecordOperationException` will now be caught as it should. `StopRecordOperationException` is always caught in REST requests and will not be reported as an exception in the response. Resolves: #67
1 parent 6ded692 commit e4367c7

3 files changed

Lines changed: 31 additions & 16 deletions

File tree

Classes/Command/CreateCommandController.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
6464
throw $exception;
6565
}
6666

67-
(new UpdateRecordOperation(
68-
$data,
69-
$input->getArgument('endpoint'),
70-
$remoteId,
71-
$input->getArgument('language'),
72-
$input->getArgument('workspace'),
73-
$input->getOption('metaData')
74-
))();
67+
try {
68+
(new UpdateRecordOperation(
69+
$data,
70+
$input->getArgument('endpoint'),
71+
$remoteId,
72+
$input->getArgument('language'),
73+
$input->getArgument('workspace'),
74+
$input->getOption('metaData')
75+
))();
76+
} catch (StopRecordOperationException $exception) {
77+
$output->writeln($exception->getMessage(), OutputInterface::VERBOSITY_VERY_VERBOSE);
78+
79+
continue;
80+
}
7581
} catch (\Throwable $exception) {
7682
$exceptions[] = $exception;
7783
}

Classes/Command/UpdateCommandController.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
6464
throw $exception;
6565
}
6666

67-
(new CreateRecordOperation(
68-
$data,
69-
$input->getArgument('endpoint'),
70-
$remoteId,
71-
$input->getArgument('language'),
72-
$input->getArgument('workspace'),
73-
$input->getOption('metaData')
74-
))();
67+
try {
68+
(new CreateRecordOperation(
69+
$data,
70+
$input->getArgument('endpoint'),
71+
$remoteId,
72+
$input->getArgument('language'),
73+
$input->getArgument('workspace'),
74+
$input->getOption('metaData')
75+
))();
76+
} catch (StopRecordOperationException $exception) {
77+
$output->writeln($exception->getMessage(), OutputInterface::VERBOSITY_VERY_VERBOSE);
78+
79+
continue;
80+
}
7581
} catch (\Throwable $exception) {
7682
$exceptions[] = $exception;
7783
}

Classes/RequestHandler/AbstractRecordRequestHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Pixelant\Interest\Context;
88
use Pixelant\Interest\Database\RelationHandlerWithoutReferenceIndex;
9+
use Pixelant\Interest\DataHandling\Operation\Event\Exception\StopRecordOperationException;
910
use Pixelant\Interest\DataHandling\Operation\Exception\AbstractException;
1011
use Pixelant\Interest\RequestHandler\ExceptionConverter\OperationToRequestHandlerExceptionConverter;
1112
use Psr\Http\Message\ResponseInterface;
@@ -335,6 +336,8 @@ protected function handleOperations(&$operationCount = 0): array
335336

336337
try {
337338
$this->handleSingleOperation($table, $remoteId, $language, $workspace, $data);
339+
} catch (StopRecordOperationException $exception) {
340+
continue;
338341
} catch (AbstractException $exception) {
339342
$exceptions[$table][$remoteId][$language][$workspace] = $exception;
340343
}

0 commit comments

Comments
 (0)