Bug 11242: fix opac-MARCdetail.pl display and warnings

This patch improves the public catalog MARC view display
of records that contain subfields that are not defined in
the framework used by the bib record.

To test:

(RM note: it may be easier to find or create a MARC record that
 contains a subfield not present in the default framework, then
 load it, rather than fiddle with the MARC frameworks in your
 test database.)

BACK UP YOUR DATABASE!
 1) Search for an item in OPAC
 2) Open OPAC detail
 3) Click 'MARC View' link
 4) Look for something with multiple lines (e.g. 260 or 942)
 5) In another tab, Go to staff client and log in
 6) Go to the staff client URL similar to:
     /cgi-bin/koha/catalogue/detail.pl?biblionumber=##### page
    where ##### is the biblionumber.
 7) Edit -> record
 8) Note the framework used.
 9) More -> Administration
10) MARC bibliographic frameworks
11) Click 'MARC structure' for the framework used by the item
     shown in OPAC.
12) Find the tag (e.g. 260 or 942) and click 'Subfields'
13) Delete of the matching subfields (e.g. 260$b) shown in the
     OPAC tab
14) Clear your opac error log.
15) Refresh OPAC tab. The tag subfields are split.
16) There are opac-MARCdetail.pl warnings.
17) Apply patch
18) Clear your opac error log.
19) Refresh OPAC tab. The tag subfields are no longer split strangely.
20) There are no opac-MARCdetail.pl warnings.
RESTORE YOUR DATABASE.

This also silences a series of warnings triggered by catching
undef hash references.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Mark Tompsett 2013-11-13 15:55:24 -05:00 committed by Galen Charlton
parent ec206d1898
commit 38503e18a3

View file

@ -1,26 +1,28 @@
#!/usr/bin/perl
# Copyright 2000-2002 Katipo Communications
# Parts copyright 2010 BibLibre
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# Copyright (C) 2000-2002 Katipo Communications
# Parts Copyright (C) 2010 BibLibre
# Parts Copyright (C) 2013 Mark Tompsett
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
=head1 NAME
MARCdetail.pl : script to show a biblio in MARC format
opac-MARCdetail.pl : script to show a biblio in MARC format
=head1 SYNOPSIS
@ -41,8 +43,7 @@ the items attached to the biblio
=cut
use strict;
use warnings;
use Modern::Perl;
use C4::Auth;
use C4::Context;
@ -172,12 +173,20 @@ for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) {
# loop through each subfield
for my $i ( 0 .. $#subf ) {
$subf[$i][0] = "@" unless defined($subf[$i][0]);
my $sf_def = $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] };
next if ( ($sf_def->{tab}||0) != $tabloop );
next if ( ($sf_def->{hidden}||0) > 0 );
my $sf_def = $tagslib->{ $fields[$x_i]->tag() };
$sf_def = $sf_def->{ $subf[$i][0] } if defined($sf_def);
my ($tab,$hidden,$lib);
$tab = $sf_def->{tab} if defined($sf_def);
$tab = $tab // int($fields[$x_i]->tag()/100);
$hidden = $sf_def->{hidden} if defined($sf_def);
$hidden = $hidden // 0;
next if ( $tab != $tabloop );
next if ( $hidden > 0 );
my %subfield_data;
$subfield_data{marc_lib} = ($sf_def->{lib} eq $previous) ? '--' : $sf_def->{lib};
$previous = $sf_def->{lib};
$lib = $sf_def->{lib} if defined($sf_def);
$lib = $lib // '--';
$subfield_data{marc_lib} = ($lib eq $previous) ? '--' : $lib;
$previous = $lib;
$subfield_data{link} = $sf_def->{link};
$subf[$i][1] =~ s/\n/<br\/>/g;
if ( $sf_def->{isurl} ) {
@ -211,12 +220,13 @@ for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) {
$tag_data{tag} = $tagslib->{ $fields[$x_i]->tag() }->{lib};
}
else {
$tag_data{tag} =
$fields[$x_i]->tag()
. ' '
my $sf_def = $tagslib->{ $fields[$x_i]->tag() };
my $lib;
$lib = $sf_def->{lib} if defined($sf_def);
$lib = $lib // '';
$tag_data{tag} = $fields[$x_i]->tag() . ' '
. C4::Koha::display_marc_indicators($fields[$x_i])
. ' - '
. $tagslib->{ $fields[$x_i]->tag() }->{lib};
. " - $lib";
}
}
my @tmp = @subfields_data;