From b878ab017cca8709daeb24af3f24b8a04f1648aa Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 3 May 2018 12:33:19 +0200 Subject: [PATCH] Bug 20697: Bind calling GetAnalyticsCount to pref EasyAnalyticalRecords If you do not use the EasyAnalyticalRecords feature (introduced with bug 5528), you will have a lot of warnings in zebra-output.log like: zebrasrv(1096) [request] Search biblios ERROR 114 1 1+0 RPN @attrset Bib-1 @attr 1=8911 259186 They come from C4::Items::GetAnalyticsCount called by catalogue/detail.pl. This sub starts a Zebra search on index 'hi' (Host-Item-Number). If you do not use this field at all (related to 773$9 in MARC21), Zebra returns an Unsupported Use attribute error (114). In making this change, I added one minor change: [1] Remove the commented GetAnalyticsCount in additem.pl and correcting indentation in that loop (removing tabs). So no change at all there. NOTE: I will propose to bind the GetHostItemsInfo call in detail.pl and two other scripts to this preference too on report 20702. Test plan: [1] If you use EasyAnalytics, verify that there is no change. [2] If you do not, check the zebra-output.log. You should no longer see searches for Host-Item-Number with 1=8911. (As well as ERROR 114 on this index.) Signed-off-by: Marcel de Rooy Signed-off-by: Charles Farmer --- catalogue/detail.pl | 2 +- cataloguing/additem.pl | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 86a0698..d7bc2c7 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -298,7 +298,7 @@ foreach my $item (@items) { } #count if item is used in analytical bibliorecords - my $countanalytics= GetAnalyticsCount($item->{itemnumber}); + my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0; if ($countanalytics > 0){ $analytics_flag=1; $item->{countanalytics} = $countanalytics; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 5cb0809..f66c000 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -798,22 +798,16 @@ foreach my $field (@fields) { } $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield); - if ( C4::Context->preference('EasyAnalyticalRecords') ) { - foreach my $hostitemnumber (@hostitemnumbers){ - my $item = Koha::Items->find( $hostitemnumber ); - if ($this_row{itemnumber} eq $hostitemnumber){ - $this_row{hostitemflag} = 1; - $this_row{hostbiblionumber}= $item->biblio->biblionumber; - last; - } - } - -# my $countanalytics=GetAnalyticsCount($this_row{itemnumber}); -# if ($countanalytics > 0){ -# $this_row{countanalytics} = $countanalytics; -# } - } - + if ( C4::Context->preference('EasyAnalyticalRecords') ) { + foreach my $hostitemnumber (@hostitemnumbers) { + my $item = Koha::Items->find( $hostitemnumber ); + if ($this_row{itemnumber} eq $hostitemnumber) { + $this_row{hostitemflag} = 1; + $this_row{hostbiblionumber}= $item->biblio->biblionumber; + last; + } + } + } } if (%this_row) { push(@big_array, \%this_row); -- 2.7.4