From 53c5b99dacec52368de9ed359e955e1177fd03a2 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 11 Jul 2023 10:52:18 +0200 Subject: [PATCH] [BUGFIX] Persist collection to prevent duplicates (#983) --- Classes/Command/BaseCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 0fd39da1f8..2db3975825 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -176,6 +176,7 @@ protected function saveToDatabase(Document $document) if ($doc === null) { return false; } + $persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $doc->cPid = $this->storagePid; $metadata = $doc->getTitledata($this->storagePid); @@ -212,6 +213,8 @@ protected function saveToDatabase(Document $document) $documentCollection->setDescription(''); // add to CollectionRepository $this->collectionRepository->add($documentCollection); + // persist collection to prevent duplicates + $persistenceManager->persistAll(); } // add to document $document->addCollection($documentCollection); @@ -273,7 +276,6 @@ protected function saveToDatabase(Document $document) $this->documentRepository->update($document); } - $persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $persistenceManager->persistAll(); return true;