diff --git a/app/src/Lib/Match/MatchService.php b/app/src/Lib/Match/MatchService.php index 74f90202e..114808859 100644 --- a/app/src/Lib/Match/MatchService.php +++ b/app/src/Lib/Match/MatchService.php @@ -679,6 +679,17 @@ public function searchReferenceId(string $sor, string $sorid, AttributeManager $ // Next try potential matches $potentialMatches = $this->search(ConfidenceModeEnum::Potential, $sor, $sorid, $attributes); + // The calling code generally checks to see if any rules successfully ran, + // since if there were no valid attributes or rules we treat that as an error. + // If no potential rules ran, we return the canonicalMatches result instead. + // (If no canonical rules ran, it doesn't matter which we return, but if at + // least one did, this is how we indicate at least something tried to happen.) + // See also CO-2127. + + if(empty($potentialMatches->getSuccessfulRules())) { + return $canonicalMatches; + } + return $potentialMatches; }