Skip to content

Commit

Permalink
[FINNA-1734] Check that a record referenced by a dedup record was fou…
Browse files Browse the repository at this point in the history
…nd before updating it.
  • Loading branch information
EreMaijala committed Jan 23, 2024
1 parent 4facec9 commit b9b7781
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/RecordManager/Base/Deduplication/DedupHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,14 +702,15 @@ public function removeFromDedupRecord($dedupId, $id)
$dedupRecord['ids'] = [];
$dedupRecord['deleted'] = true;

$otherRecord = $this->db->getRecord($otherId);
if (isset($otherRecord['dedup_id'])) {
unset($otherRecord['dedup_id']);
}
if (!$otherRecord['deleted'] && empty($otherRecord['suppressed'])) {
$otherRecord['update_needed'] = true;
if (null !== ($otherRecord = $this->db->getRecord($otherId))) {
if (isset($otherRecord['dedup_id'])) {
unset($otherRecord['dedup_id']);
}
if (!$otherRecord['deleted'] && empty($otherRecord['suppressed'])) {
$otherRecord['update_needed'] = true;
}
$this->db->saveRecord($otherRecord);
}
$this->db->saveRecord($otherRecord);
} elseif (empty($dedupRecord['ids'])) {
// No records remaining => just mark dedup record deleted.
// This shouldn't happen since a dedup record should always contain
Expand Down

0 comments on commit b9b7781

Please sign in to comment.