From 462f15815686dd96e800f3f4bbd9e0e44565d468 Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Tue, 28 May 2024 10:26:04 -0400 Subject: [PATCH] Rollback Identifiers::lookupPerson function signature as changed by 4b3bc03c88 for CFM-291 --- app/src/Model/Table/IdentifiersTable.php | 37 +++++++----------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/app/src/Model/Table/IdentifiersTable.php b/app/src/Model/Table/IdentifiersTable.php index d557dd80b..144ad8d7c 100644 --- a/app/src/Model/Table/IdentifiersTable.php +++ b/app/src/Model/Table/IdentifiersTable.php @@ -202,32 +202,17 @@ public function localAfterSave(\Cake\Event\EventInterface $event, \Cake\Datasour * @since COmanage Registry v5.0.0 */ - public function lookupPerson(int $typeId, string $identifier, ?int $coId, bool $login=false): int { - $whereClause = [ - 'identifier' => $identifier, - 'status' => SuspendableStatusEnum::Active, - 'person_id IS NOT NULL' - ]; - - if($typeId) { - $whereClause['type_id'] = $typeId; - } - - if($login) { - $whereClause['login'] = true; - } - - $query = $this->find() - ->where($whereClause); - - if($coId) { - $query->matching( - 'People', - fn(QueryExpression $exp, Query $query) => $query->where(['People.co_id' => $coId]) - ); - } - - $id = $query->firstOrFail(); + public function lookupPerson(int $typeId, string $identifier): int { + // Note this function signature is intentionally the same as + // EmailAddresses::lookupPerson() + $id = $this->find() + ->where([ + 'identifier' => $identifier, + 'type_id' => $typeId, + 'status' => SuspendableStatusEnum::Active, + 'person_id IS NOT NULL' + ]) + ->firstOrFail(); return $id->person_id; }