Skip to content

Commit

Permalink
[BUGFIX] Persist collection to prevent duplicates (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizzor authored and sebastian-meyer committed Sep 15, 2023
1 parent ddaaf04 commit 0d590cc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Classes/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,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);
Expand Down Expand Up @@ -223,6 +224,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);
Expand Down Expand Up @@ -284,7 +287,6 @@ protected function saveToDatabase(Document $document)
$this->documentRepository->update($document);
}

$persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
$persistenceManager->persistAll();

return true;
Expand Down

0 comments on commit 0d590cc

Please sign in to comment.