Bug 42156: Attempt to repair corrupted records and skip when not possible
When matching authorities we can die on a bad record, we should add protection against this
on top of bug 41843
To test:
1 - Apply index patch and rebuild elastic
perl misc/search_tools/rebuild_elasticsearch.pl -r -v
2 - Make a new record matching rule
threshold: 1000
type: authority
index: authid
score: 1000
tag: 001
3 - Choose an authority record and corrupt it:
sudo koha-mysql kohadev
UPDATE auth_header SET marcxml = UpdateXML(marcxml, '//datafield[@tag="040"]/subfield[@code="c"]',CONCAT('<subfield code',CHAR(27),'="c">OSt</subfield>')) WHERE auth_header.authid=92;
4 - View and save the record as marcxml
http://localhost:8081/cgi-bin/koha/authorities/detail.pl?authid=92
5 - Cataloging - stage marc records - authority/marcxml/no matching
6 - Confirm it stages
7 - Attempt to match using your new rule
8 - Get an error parsing the marc
9 - Apply patch, restart all
10 - Relaod the staged batch
11 - Attempt matching agaion
12 - Success!
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c5adbe0818)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
parent
190d132268
commit
a2584a71f4
|
|
@ -752,8 +752,16 @@ sub get_matches {
|
|||
my ( $authresults, $total ) = $searcher->search_auth_compat( $search_query, 0, 20 );
|
||||
|
||||
foreach my $result (@$authresults) {
|
||||
my $id = $result->{authid};
|
||||
my $target_record = Koha::Authorities->find($id)->record;
|
||||
my $id = $result->{authid};
|
||||
my $target_auth = Koha::Authorities->find($id);
|
||||
my $target_record = eval { $target_auth->record };
|
||||
my $invalid_record = $@ || !$target_record;
|
||||
if ($invalid_record) {
|
||||
warn
|
||||
"Error parsing matched authority record $id, attempting to clean record, record will be skipped if it fails";
|
||||
$target_record = $target_auth->record_strip_nonxml;
|
||||
}
|
||||
next unless $target_record;
|
||||
$matches->{$id}->{score} += $matchpoint->{'score'};
|
||||
$matches->{$id}->{record} = $target_record;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue