diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php index 9a769e222d..326e3c7b6d 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php @@ -108,7 +108,18 @@ class SubdefCreationWorker implements WorkerInterface $this->subdefGenerator->setLogger($this->logger); - $this->subdefGenerator->generateSubdefs($record, $wantedSubdef); + try { + $this->subdefGenerator->generateSubdefs($record, $wantedSubdef); + } catch (\Exception $e) { + $em->beginTransaction(); + try { + $em->remove($workerRunningJob); + $em->flush(); + $em->commit(); + } catch (\Exception $e) { + $em->rollback(); + } + } // begin to check if the subdef is successfully generated $subdef = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType())->getSubdef($payload['subdefName']);