[Patches] [PATCH] Bug 7311: Only run analytics code if analytics are enabled
koha-patchbot at kohaaloha.com
koha-patchbot at kohaaloha.com
Sat Dec 3 14:16:11 NZDT 2011
From: Jared Camins-Esakov <jcamins at cpbibliography.com>
Date: Fri, 2 Dec 2011 08:27:45 -0500
Subject: [PATCH] Bug 7311: Only run analytics code if analytics are enabled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"
With the addition of the code from Bug 5528 (easy analytic record workflows),
UNIMARC 461$0 and MARC21/NORMARC 773$0 have special meanings. When you import
a record that uses those subfields for different data, you will get an error
in /cataloguing/additem.pl. A check should be added to be sure that
EasyAnalyticalRecords is enabled before trying to handle the 461$0/773$0 as
bib numbers for analytics.
Thanks to Frère Sébastien Marie for spotting this issue.
---
cataloguing/additem.pl | 32 +++++++++++++++++---------------
1 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index 4442ed3..ffe5f13 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -544,21 +544,23 @@ C4::Biblio::EmbedItemsInMarcBiblio($temp, $biblionumber);
my @fields = $temp->fields();
-my @hostitemnumbers;
-my $analyticfield = '773';
-if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC') {
- $analyticfield = '773';
-} elsif ($marcflavour eq 'UNIMARC') {
- $analyticfield = '461';
-}
-foreach my $hostfield ($temp->field($analyticfield)){
- if ($hostfield->subfield('0')){
- my $hostrecord = GetMarcBiblio($hostfield->subfield('0'), 1);
- my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostfield->subfield('0')) );
- foreach my $hostitem ($hostrecord->field($itemfield)){
- if ($hostitem->subfield('9') eq $hostfield->subfield('9')){
- push (@fields, $hostitem);
- push (@hostitemnumbers, $hostfield->subfield('9'));
+if (C4::Context->preference('EasyAnalyticalRecords')) {
+ my @hostitemnumbers;
+ my $analyticfield = '773';
+ if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC') {
+ $analyticfield = '773';
+ } elsif ($marcflavour eq 'UNIMARC') {
+ $analyticfield = '461';
+ }
+ foreach my $hostfield ($temp->field($analyticfield)){
+ if ($hostfield->subfield('0')){
+ my $hostrecord = GetMarcBiblio($hostfield->subfield('0'), 1);
+ my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostfield->subfield('0')) );
+ foreach my $hostitem ($hostrecord->field($itemfield)){
+ if ($hostitem->subfield('9') eq $hostfield->subfield('9')){
+ push (@fields, $hostitem);
+ push (@hostitemnumbers, $hostfield->subfield('9'));
+ }
}
}
}
--
1.7.2.5
More information about the Patches
mailing list