From d6248c23cf147e259f6c05175fe44b785372a6a3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 4 Sep 2017 12:06:56 -0300 Subject: [PATCH] Bug 18927: Use fully qualified subroutine names in C4::Items Content-Type: text/plain; charset=utf-8 rebuild_zebra.pl fails in some conditions (perl version?) I do not recreate but it has been reported that reindex fails with: error retrieving biblio 94540 at /usr/share/koha/bin/migration_tools/rebuild_zebra.pl line 683, line 751. To fix it we can use fully qualified subroutine names for: GetMarcFromKohaField GetMarcBiblio GetBiblionumberFromItemnumber TransformKohaToMarc GetFrameworkCode Test plan: Confirm the rebuild_zebra script still works correctly after this patch Signed-off-by: Lee Jamison Signed-off-by: Marcel de Rooy --- C4/Items.pm | 30 +++++++++++++++--------------- misc/migration_tools/rebuild_zebra.pl | 8 ++++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 18debb5..0b6a77e 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -235,8 +235,8 @@ sub AddItemFromMarc { my $dbh = C4::Context->dbh; # parse item hash from MARC - my $frameworkcode = GetFrameworkCode( $biblionumber ); - my ($itemtag,$itemsubfield)=GetMarcFromKohaField("items.itemnumber",$frameworkcode); + my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); + my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode); my $localitemmarc=MARC::Record->new; $localitemmarc->append_fields($source_item_marc->field($itemtag)); @@ -271,7 +271,7 @@ sub AddItem { my $biblionumber = shift; my $dbh = @_ ? shift : C4::Context->dbh; - my $frameworkcode = @_ ? shift : GetFrameworkCode($biblionumber); + my $frameworkcode = @_ ? shift : C4::Biblio::GetFrameworkCode($biblionumber); my $unlinked_item_subfields; if (@_) { $unlinked_item_subfields = shift; @@ -364,7 +364,7 @@ sub AddItemBatchFromMarc { $record = $record->clone(); # loop through the item tags and start creating items my @bad_item_fields = (); - my ($itemtag, $itemsubfield) = &GetMarcFromKohaField("items.itemnumber",''); + my ($itemtag, $itemsubfield) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",''); my $item_sequence_num = 0; ITEMFIELD: foreach my $item_field ($record->field($itemtag)) { $item_sequence_num++; @@ -499,8 +499,8 @@ sub ModItemFromMarc { my $itemnumber = shift; my $dbh = C4::Context->dbh; - my $frameworkcode = GetFrameworkCode($biblionumber); - my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); + my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber); + my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); my $localitemmarc = MARC::Record->new; $localitemmarc->append_fields( $item_marc->field($itemtag) ); @@ -552,7 +552,7 @@ sub ModItem { } my $dbh = @_ ? shift : C4::Context->dbh; - my $frameworkcode = @_ ? shift : GetFrameworkCode( $biblionumber ); + my $frameworkcode = @_ ? shift : C4::Biblio::GetFrameworkCode( $biblionumber ); my $unlinked_item_subfields; if (@_) { @@ -1321,7 +1321,7 @@ references on array of itemnumbers. sub get_hostitemnumbers_of { my ($biblionumber) = @_; - my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber }); + my $marcrecord = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); return unless $marcrecord; @@ -1479,7 +1479,7 @@ sub GetMarcItem { my $itemrecord = GetItem($itemnumber); - # Tack on 'items.' prefix to column names so that TransformKohaToMarc will work. + # Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. # Also, don't emit a subfield if the underlying field is blank. @@ -1493,8 +1493,8 @@ sub Item2Marc { defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () } keys %{ $itemrecord } }; - my $itemmarc = TransformKohaToMarc($mungeditem); - my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",GetFrameworkCode($biblionumber)||''); + my $itemmarc = C4::Biblio::TransformKohaToMarc($mungeditem); + my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",C4::Biblio::GetFrameworkCode($biblionumber)||''); my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'}); if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) { @@ -2120,7 +2120,7 @@ sub _marc_from_item_hash { my $item_marc = MARC::Record->new(); foreach my $item_field ( keys %{$mungeditem} ) { - my ( $tag, $subfield ) = GetMarcFromKohaField( $item_field, $frameworkcode ); + my ( $tag, $subfield ) = C4::Biblio::GetMarcFromKohaField( $item_field, $frameworkcode ); next unless defined $tag and defined $subfield; # skip if not mapped to MARC field my @values = split(/\s?\|\s?/, $mungeditem->{$item_field}, -1); foreach my $value (@values){ @@ -2334,7 +2334,7 @@ sub _SearchItems_build_where_fragment { # items.more_subfields_xml, depending on the MARC field. my $xpath; my $sqlfield; - my ($itemfield) = GetMarcFromKohaField('items.itemnumber'); + my ($itemfield) = C4::Biblio::GetMarcFromKohaField('items.itemnumber'); if ($marcfield eq $itemfield) { $sqlfield = 'more_subfields_xml'; $xpath = '//record/datafield/subfield[@code="' . $marcsubfield . '"]'; @@ -2541,8 +2541,8 @@ sub PrepareItemrecordDisplay { my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_; my $dbh = C4::Context->dbh; - $frameworkcode = &GetFrameworkCode($bibnum) if $bibnum; - my ( $itemtagfield, $itemtagsubfield ) = &GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); + $frameworkcode = C4::Biblio::GetFrameworkCode($bibnum) if $bibnum; + my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); # Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is # a shared data structure. No plugin (including custom ones) should change diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index 5e43cd6..c3f41df 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -172,8 +172,8 @@ my $kohadir = C4::Context->config('intranetdir'); my $bib_index_mode = C4::Context->config('zebra_bib_index_mode') // 'dom'; my $auth_index_mode = C4::Context->config('zebra_auth_index_mode') // 'dom'; -my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber",""); -my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber",""); +my ($biblionumbertagfield,$biblionumbertagsubfield) = C4::Biblio::GetMarcFromKohaField("biblio.biblionumber",""); +my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = C4::Biblio::GetMarcFromKohaField("biblioitems.biblioitemnumber",""); my $marcxml_open = q{ @@ -497,7 +497,7 @@ sub export_marc_records_from_sth { print {$fh} $marcxml_open; my $i = 0; - my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",''); + my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",''); while (my ($record_number) = $sth->fetchrow_array) { print "." if ( $verbose_logging ); print "\r$i" unless ($i++ %100 or !$verbose_logging); @@ -675,7 +675,7 @@ sub get_raw_marc_record { my $marc; if ($record_type eq 'biblio') { - eval { $marc = GetMarcBiblio({ biblionumber => $record_number, embed_items => 1 }); }; + eval { $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $record_number, embed_items => 1 }); }; if ($@ || !$marc) { # here we do warn since catching an exception # means that the bib was found but failed -- 2.1.4