|
|
@@ -101,25 +101,25 @@ class CleanWorkToDo extends BaseCronJob
|
|
|
$this->connection->beginTransaction();
|
|
|
|
|
|
try {
|
|
|
- // Set DELETION_REQUESTED status for all associated files
|
|
|
- $files = $work->getFiles();
|
|
|
+ $workId = $work->getId();
|
|
|
|
|
|
- foreach ($files as $file) {
|
|
|
- if ($this->storage->support($file)) {
|
|
|
- $file->setStatus(FileStatusEnum::DELETION_REQUESTED);
|
|
|
- $this->entityManager->persist($file);
|
|
|
- }
|
|
|
- }
|
|
|
+ // Set DELETION_REQUESTED status for all associated files
|
|
|
+ $this->connection->executeStatement(
|
|
|
+ "UPDATE file SET status = ? WHERE work_id = ? AND host = ?",
|
|
|
+ [FileStatusEnum::DELETION_REQUESTED->value, $workId, FileHostEnum::AP2I->value]
|
|
|
+ );
|
|
|
|
|
|
// Delete WorkByUser records
|
|
|
- foreach ($work->getWorkByUsers() as $workByUser) {
|
|
|
- $this->entityManager->remove($workByUser);
|
|
|
- }
|
|
|
+ $this->connection->executeStatement(
|
|
|
+ "DELETE FROM work_by_user WHERE work_id = ?",
|
|
|
+ [$workId]
|
|
|
+ );
|
|
|
|
|
|
// Delete the work itself
|
|
|
- $this->entityManager->remove($work);
|
|
|
-
|
|
|
- $this->entityManager->flush();
|
|
|
+ $this->connection->executeStatement(
|
|
|
+ "DELETE FROM work WHERE id = ?",
|
|
|
+ [$workId]
|
|
|
+ );
|
|
|
|
|
|
$this->connection->commit();
|
|
|
|
|
|
@@ -127,6 +127,9 @@ class CleanWorkToDo extends BaseCronJob
|
|
|
} catch (\RuntimeException|\InvalidArgumentException $e) {
|
|
|
$this->logger->error('ERROR deleting work '.$work->getId().': '.$e->getMessage());
|
|
|
$this->connection->rollback();
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ $this->connection->rollback();
|
|
|
+ throw $exception;
|
|
|
}
|
|
|
}
|
|
|
|