Skip to content

Commit

Permalink
Improve findForCoRecord (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jan 19, 2024
1 parent ad6c300 commit 39b6778
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/Lib/Traits/PrimaryLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ public function calculateCoForRecord(EntityInterface $entity, bool $original=fal
* #since COmanage Registry v5.0.0
* @param int $id Record ID
* @return int|null CO ID or null if not found
* @throws Cake\Datasource\Exception\RecordNotFoundException
*/

public function findCoForRecord(int $id): ?int {
// Pull the object to examine the primary links
$query = $this->findById($id);

// This will throw an error on failure
return $this->calculateCoForRecord($query->firstOrFail());
// Pull the object to examine the primary links. We might be asked to find the
// CO for a deleted object (eg: to add a history record, or to show an older
// value for an entity), so accept archived records.
return $this->calculateCoForRecord($this->get($id, ['archived' => true]));
}

/**
Expand Down

0 comments on commit 39b6778

Please sign in to comment.