[Koha-patches] [PATCH] Bug 5572: Changes to sub merge in C4::AuthoritiesMarc to refine authorities merging -- safer version

Janusz Kaczmarek januszop at gmail.com
Fri Jan 20 21:47:01 CET 2012


---
 C4/AuthoritiesMarc.pm |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index b3c5070..eb3cd99 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -1338,6 +1338,13 @@ sub merge {
         $oConnection->option("preferredRecordSyntax"=>$oldSyntax);
     }
     #warn scalar(@reccache)." biblios to update";
+    #Get a list of authority controlled subfields
+    $sth = $dbh->prepare("select distinct tagsubfield from auth_subfield_structure where authtypecode=? and tagfield=? and tab >=0 and hidden = 0");
+    $sth->execute($authtypecodeto, $auth_tag_to_report_to);
+    my @subfields_controlled_by_auth_to;
+    while (my ($tagsubfield) = $sth->fetchrow) {
+        push @subfields_controlled_by_auth_to, $tagsubfield ;
+    }
     # Get All candidate Tags for the change 
     # (This will reduce the search scope in marc records).
     $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
@@ -1370,6 +1377,9 @@ sub merge {
                     $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
 		    $exclude.= $subfield->[0];
                 }
+		foreach my $subt (@subfields_controlled_by_auth_to) {
+		    $exclude.= $subt;
+		}
 		$exclude='['.$exclude.']';
 #		add subfields in $field not included in @record_to
 		my @restore= grep {$_->[0]!~/$exclude/} $field->subfields();
-- 
1.7.2.5



More information about the Koha-patches mailing list