Skip to content

Commit

Permalink
Fix handling of invalidated searches (CO-2786)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jan 26, 2026
1 parent e33f9d7 commit 1816679
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
51 changes: 33 additions & 18 deletions app/src/Lib/Match/MatchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,19 @@ public function searchReferenceId(string $sor, string $sorid, AttributeManager $

Log::write('debug', $sor . "/" . $sorid . " Invalidate mode for $ruleAttributeName ($rulename) downgrading result to Potential");

// An invalidated match could have matched more than one $rowId.
// We only check one $rowId per outer foreach() loop, but if any
// row invalidates then the entire match is invalidated. There's
// probably an argument to be made that if one row invalidates and
// a second doesn't it's still a valid match, but we don't treat it
// that way because (1) there is some inconsistency in the data
// according to its configuration, so an administrator should look
// at it before we link another record in, and (2) it's logically
// simpler.

$downgraded = [
'rule' => "_invalidate",
'attrs' => $attrs
'results' => $results
];

// No need to continue with any loop
Expand All @@ -925,29 +935,29 @@ public function searchReferenceId(string $sor, string $sorid, AttributeManager $
// Next we need to handle Potential Trust Mode, check to see if any result row
// matched the SOR.

if($trustMode != TrustModeEnum::Potential) {
// Exact match, return
return $canonicalMatches;
}
if($trustMode != TrustModeEnum::Potential) {
// Exact match, return
return $canonicalMatches;
}

foreach($results as $rowId => $attrs) {
if($attrs['sor'] == $sor) {
$sorMatch = $attrs;
break;
foreach($results as $rowId => $attrs) {
if($attrs['sor'] == $sor) {
$sorMatch = $attrs;
break;
}
}
}

if(!$sorMatch) {
// We matched against a _different_ SOR, so return a canonical match
if(!$sorMatch) {
// We matched against a _different_ SOR, so return a canonical match

return $canonicalMatches;
}
return $canonicalMatches;
}

$downgraded = [
'rule' => "_trustmode",
'attrs' => $sorMatch
'results' => $results
];
Log::write('debug', $sor . "/" . $sorid . " Trust Mode downgrading result to Potential");
Log::write('debug', $sor . "/" . $sorid . " Trust Mode downgrading result to Potential");
}
break;
case 0:
Expand All @@ -974,8 +984,13 @@ public function searchReferenceId(string $sor, string $sorid, AttributeManager $
// Add in the downgraded potential match from above, if configured

if($downgraded !== false) {
// We use a psuedo-rule name
$potentialMatches->add($downgraded['attrs'], $downgraded['rule']);
// We use a psuedo-rule name. Note a canonical match with 1 result may
// still have matched multiple rows, and we need to add them all so the
// reconciliation page will show the correct options.

foreach($downgraded['results'] as $rowId => $attrs) {
$potentialMatches->add($attrs, $downgraded['rule']);
}
}

// The calling code generally checks to see if any rules successfully ran,
Expand Down
1 change: 0 additions & 1 deletion app/src/Lib/Match/ResultManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class ResultManager {
* Add a Matchgrid result.
*
* @since COmanage Match v1.0.0
* @param string $referenceId Reference ID
* @param array $attributes Array of matchgrid attributes
* @param string $rule Rule that generated this result
* @throws RuntimeException
Expand Down

0 comments on commit 1816679

Please sign in to comment.