Bug 39436 - C4/Matcher does not check if the biblio returned by search exists in DB
Summary: C4/Matcher does not check if the biblio returned by search exists in DB
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-24 15:29 UTC by Baptiste Wojtkowski (bwoj)
Modified: 2025-03-26 09:13 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
BZ39436: Have the matcher check the existence of the record returned by search engine (1.17 KB, patch)
2025-03-26 09:13 UTC, Baptiste Wojtkowski (bwoj)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Baptiste Wojtkowski (bwoj) 2025-03-24 15:29:48 UTC
C4/Matcher does not check if the biblio returned by search exists in DB. This can be a problem for example if you then try to attach a command to the biblio
Comment 1 Baptiste Wojtkowski (bwoj) 2025-03-24 15:31:56 UTC
Solution should look like this, but I don't have a testplan :

diff --git a/C4/Matcher.pm b/C4/Matcher.pm
index 9369782f..8c6075f6 100644
--- a/C4/Matcher.pm
+++ b/C4/Matcher.pm
@@ -721,8 +721,11 @@ sub get_matches {
                         ( $biblionumber_tag > 10 )
                         ? $target_record->field($biblionumber_tag)->subfield($biblionumber_subfield)
                         : $target_record->field($biblionumber_tag)->data();
-                    $matches->{$id}->{score} += $matchpoint->{score};
-                    $matches->{$id}->{record} = $target_record;
+                    my $biblio = Koha::Biblio->find($id);
+                    if ($biblio){
+                        $matches->{$id}->{score} += $matchpoint->{score};
+                        $matches->{$id}->{record} = $target_record;
+                    }
                 }
             }
Comment 2 David Cook 2025-03-24 22:17:42 UTC
I'd imagine the test plan would be to create the record in the DB and index it, export the record, turn off the background indexer, delete the record, import the record with a matching rule for the Koha identifier (e.g. 999$c in MARC21 - not sure of UNIMARC equivalent).
Comment 3 Baptiste Wojtkowski (bwoj) 2025-03-26 09:12:57 UTC
Hi David, thx for the test plan ! Do you know how to stop the background indexer in ktd ?
Comment 4 Baptiste Wojtkowski (bwoj) 2025-03-26 09:13:34 UTC
Created attachment 179717 [details] [review]
BZ39436: Have the matcher check the existence of the record returned by search engine

TEST PLAN:
TBD