[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:13 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 | 48 ++++++++++++++++++++++++++----------------------
1 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index 4442ed3..03a50bf 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'));
+ }
}
}
}
@@ -596,18 +598,20 @@ foreach my $field (@fields) {
}
}
$this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
- foreach my $hostitemnumber (@hostitemnumbers){
- if ($this_row{itemnumber} eq $hostitemnumber){
- $this_row{hostitemflag} = 1;
- $this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber);
- last;
- }
- }
+ if (C4::Context->preference('EasyAnalyticalRecords')) {
+ foreach my $hostitemnumber (@hostitemnumbers){
+ if ($this_row{itemnumber} eq $hostitemnumber){
+ $this_row{hostitemflag} = 1;
+ $this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber);
+ last;
+ }
+ }
# my $countanalytics=GetAnalyticsCount($this_row{itemnumber});
# if ($countanalytics > 0){
# $this_row{countanalytics} = $countanalytics;
# }
+ }
}
if (%this_row) {
--
1.7.2.5
More information about the Patches
mailing list