Skip to content

Commit

Permalink
[BUGFIX] Persist collection to prevent duplicates (kitodo#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizzor authored Jul 11, 2023
1 parent e1f3821 commit 53c5b99
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 @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -273,7 +276,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 53c5b99

Please sign in to comment.