Bug 10230: Don't limit valid matches to bibs

The patch for bug 9523 added a JOIN to the biblio table when identifying
the best match so that if a matched record had been deleted it would
not hold up the import process. Unfortunately, this broke all authority
matching, since of course authorities don't appear in the biblio table.
This patch adds a join to auth_header as well, and decides which to
check based on the record type.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment on third patch of this series.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
This commit is contained in:
Jared Camins-Esakov 2013-05-11 15:19:58 -04:00
parent 2708db5277
commit 4f9174349c

View file

@ -1036,8 +1036,12 @@ sub GetBestRecordMatch {
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT candidate_match_id
FROM import_record_matches
JOIN biblio ON ( candidate_match_id = biblionumber )
WHERE import_record_id = ?
JOIN import_records ON ( import_record_matches.import_record_id = import_records.import_record_id )
LEFT JOIN biblio ON ( candidate_match_id = biblio.biblionumber )
LEFT JOIN auth_header ON ( candidate_match_id = auth_header.authid )
WHERE import_record_matches.import_record_id = ? AND
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) )
ORDER BY score DESC, candidate_match_id DESC");
$sth->execute($import_record_id);
my ($record_id) = $sth->fetchrow_array();