From bb81900fba721b404188814d11422dc6d32c3b48 Mon Sep 17 00:00:00 2001 From: Filippos N Kolovos Date: Sun, 13 Jun 2021 19:23:06 +0300 Subject: [PATCH 1/2] Bug 19220 | Allow XSLT processing for Z39.50 authority targets like for bibliographic targets Work in this file includes a bugfix when a custom XSLT transform file has been configured for an authority Z3950 server but when the search has been previously carried out, the XSLT seems not to be working. One had to run the cleanup_database.pl tool -c --z3950 in order to clean the import tables for this to work. Similarly, if an XSLT was working and now it is removed from the configuration, then the same behaviour occurs where an "old" search still comes out formatted with the XSLT. It is in the ImportBreedingAuth() method, where for the Authorities if an import_record_id already exists in the import_records table for that authority in the import_auths table, then it simply returns the import_record_id, ignoring the new MARC data that have been returned from the new XSL transformation. If the auth record does not exist in the import_auths table, then the AddAuthToBatch() is called, which adds the auth into import_records, with the marc and marcxml correctly. In the case of biblios, it always runs the AddBiblioToBatch(), even if the biblio is already in the cache, returning the new id, hence the new marc. --- C4/Breeding.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index 6b103b3cdb..a606acc579 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -502,6 +502,8 @@ sub ImportBreedingAuth { my $batch_id = GetZ3950BatchId($filename); my $searchbreeding = $dbh->prepare("select import_record_id from import_auths where control_number=? and authorized_heading=?"); + my $marc_type = shift || C4::Context->preference('marcflavour'); + my $controlnumber = $marcrecord->field('001')->data; # Normalize the record so it doesn't have separated diacritics @@ -510,7 +512,13 @@ sub ImportBreedingAuth { $searchbreeding->execute($controlnumber,$heading); my ($breedingid) = $searchbreeding->fetchrow; - return $breedingid if $breedingid; + if ($breedingid) + { + my $updbrd = $dbh->prepare("update import_records set marc=?,marcxml=? where import_record_id=?"); + $updbrd->execute($marcrecord->as_usmarc(),$marcrecord->as_xml($marc_type),$breedingid); + $updbrd->finish(); + return $breedingid; + } $breedingid = AddAuthToBatch($batch_id, 0, $marcrecord, $encoding); return $breedingid; } -- 2.20.1