Skip to content

Commit

Permalink
Fix implementation of AR-Identifier-2 (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Oct 8, 2024
1 parent f52b216 commit bdd9226
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/src/Model/Table/IdentifiersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public function ruleUniqueIdentifier($entity, $options) {
// Note we specifically do NOT check status, since a Suspended Identifier
// will still prevent duplicate assignment. (AR-Identifier-3)
$whereClause = [
// type_id will imply CO ID, so we don't need to check it explicitly
'type_id' => $entity->type_id
];

Expand All @@ -297,6 +298,13 @@ public function ruleUniqueIdentifier($entity, $options) {
$whereClause['identifier'] = $entity->identifier;
}

// We need to only check Identifiers attached to the same type of Entity
if(!empty($entity->person_id)) {
$whereClause[] = 'person_id IS NOT NULL';
} elseif(!empty($entity->group_id)) {
$whereClause[] = 'group_id IS NOT NULL';
}

$identifier = $this->find()
->where($whereClause)
->epilog('FOR UPDATE')
Expand Down

0 comments on commit bdd9226

Please sign in to comment.