Bug 7311: Only run analytics code if analytics are enabled
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. Signed-off-by: Frère Sébastien Marie <semarie-koha@latrappe.fr> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
parent
6408547cc0
commit
97caccbd0f
|
|
@ -556,27 +556,28 @@ 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 $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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach my $field (@fields) {
|
||||
next if ( $field->tag() < 10 );
|
||||
|
||||
|
|
@ -607,18 +608,21 @@ foreach my $field (@fields) {
|
|||
}
|
||||
}
|
||||
$this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
|
||||
foreach my $hostitemnumber (@hostitemnumbers){
|
||||
|
||||
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){
|
||||
# my $countanalytics=GetAnalyticsCount($this_row{itemnumber});
|
||||
# if ($countanalytics > 0){
|
||||
# $this_row{countanalytics} = $countanalytics;
|
||||
# }
|
||||
# }
|
||||
}
|
||||
|
||||
}
|
||||
if (%this_row) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue