From 70ca93fdf0f9d066ebd1de1930f534c07fcc4d9d Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 5 Oct 2015 15:03:14 +0200 Subject: [PATCH] Bug 14560 [Follow-up]: QA: Add debug warnings and get biblionumber with GetMarcFromKohaField --- C4/AuthoritiesRameau.pm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/C4/AuthoritiesRameau.pm b/C4/AuthoritiesRameau.pm index c1ad3f4..ecb2038 100644 --- a/C4/AuthoritiesRameau.pm +++ b/C4/AuthoritiesRameau.pm @@ -27,6 +27,7 @@ use C4::AuthoritiesMarc::MARC21; use C4::AuthoritiesMarc::UNIMARC; use C4::Charset; use C4::Log; +use C4::Debug; use Koha::Authority; use vars qw($VERSION @ISA @EXPORT); @@ -85,7 +86,7 @@ sub _findLocalAuth { $rs = $ctn->search(new ZOOM::Query::CCL2RPN(C4::Context->preference('rameauBnfIdIndex') . '=' . $id, $ctn)); }; if ($@) { - print "Error searching\n"; + $debug and warn "Error searching"; return -1; } if ($rs && $rs->size() == 1) { @@ -133,7 +134,7 @@ sub addInternalLinks { if (my $kohaauthid = _findLocalAuth($subfield->[1])) { if ($kohaauthid != -1) { $found_authid = $kohaauthid; - print "Adding authid $kohaauthid\n"; + $debug and warn "Adding authid $kohaauthid"; } } } @@ -149,14 +150,25 @@ sub rameauProcessing { my $marcrecord = shift @_; my $update = 0; + # Getting biblionumber + my ($bntag, $bnsubf) = GetMarcFromKohaField('biblio.biblionumber', ''); + my $biblionumber; + if (defined $bnsubf && $bnsubf ne "@") { + $biblionumber = $marcrecord->subfield($bntag, $bnsubf); + } else { + if (defined $marcrecord->field($bntag)) { + $biblionumber = $marcrecord->field($bntag)->data(); + } + } + my @rameauFields = (600, 601, 602, 606, 607); foreach my $tag (@rameauFields) { foreach my $field ($marcrecord->field($tag)) { if (isRameau($field)) { - if ($marcrecord->field('001')) { - print "Merging Rameau for biblionumber " . $marcrecord->field('001')->data() . " field $tag\n"; + if (defined $biblionumber) { + $debug and warn "Merging Rameau for biblionumber $biblionumber field $tag"; } else { - print "Merging Rameau for an unknown biblionumber field $tag\n"; + $debug and warn "Merging Rameau for an unknown biblionumber field $tag"; } addRameau($field); addInternalLinks($field); -- 1.7.10.4