From f8dd8715879d5b2ecec76dea953f5fc93211a4c2 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Wed, 26 Sep 2018 17:25:44 +0200 Subject: [PATCH] Bug 19687: Undefined subroutine in bulkmarcimport Bulkmarcimport produces undefined subroutine error for C4::Items::TransformMarcToKoha and C4::Items::GetMarcStructure probably caused by mutually recursive modules. Put exports in BEGIN clause before all the other imports. 1) Run bulkmarcimport.pl before applying patch and verify that undefined subroutine error occurs 2) Apply patch 3) Run bulkmarcimport.pl again and verify that no errors are produced Sponsored-by: Gothenburg University Library --- C4/Biblio.pm | 147 ++++++++++++++++++++++++----------------------------------- C4/Items.pm | 90 ++++++++++++++++-------------------- 2 files changed, 100 insertions(+), 137 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 0c5a917c6b..ccc3e3a2a8 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -20,6 +20,65 @@ package C4::Biblio; # along with Koha; if not, see . use Modern::Perl; + +use vars qw(@ISA @EXPORT); +BEGIN { + require Exporter; + @ISA = qw(Exporter); + + @EXPORT = qw( + AddBiblio + GetBiblioData + GetMarcBiblio + GetRecordValue + GetISBDView + GetMarcControlnumber + GetMarcNotes + GetMarcISBN + GetMarcISSN + GetMarcSubjects + GetMarcAuthors + GetMarcSeries + GetMarcHosts + GetMarcUrls + GetUsedMarcStructure + GetXmlBiblio + GetCOinSBiblio + GetMarcPrice + MungeMarcPrice + GetMarcQuantity + GetAuthorisedValueDesc + GetMarcStructure + IsMarcStructureInternal + GetMarcFromKohaField + GetMarcSubfieldStructureFromKohaField + GetFrameworkCode + TransformKohaToMarc + PrepHostMarcField + CountItemsIssued + CountBiblioInOrders + ModBiblio + ModZebra + UpdateTotalIssues + RemoveAllNsb + DelBiblio + BiblioAutoLink + LinkBibHeadingsToAuthorities + TransformMarcToKoha + TransformHtmlToMarc + TransformHtmlToXml + prepare_host_field + ); + + # Internal functions + # those functions are exported but should not be used + # they are useful in a few circumstances, so they are exported, + # but don't use them unless you are a core developer ;-) + push @EXPORT, qw( + ModBiblioMarc + ); +} + use Carp; use Encode qw( decode is_utf8 ); @@ -49,94 +108,8 @@ use Koha::ItemTypes; use Koha::SearchEngine; use Koha::Libraries; -use vars qw(@ISA @EXPORT); use vars qw($debug $cgi_debug); -BEGIN { - - require Exporter; - @ISA = qw( Exporter ); - - # to add biblios - # EXPORTED FUNCTIONS. - push @EXPORT, qw( - &AddBiblio - ); - - # to get something - push @EXPORT, qw( - GetBiblioData - GetMarcBiblio - - &GetRecordValue - - &GetISBDView - - &GetMarcControlnumber - &GetMarcNotes - &GetMarcISBN - &GetMarcISSN - &GetMarcSubjects - &GetMarcAuthors - &GetMarcSeries - &GetMarcHosts - GetMarcUrls - &GetUsedMarcStructure - &GetXmlBiblio - &GetCOinSBiblio - &GetMarcPrice - &MungeMarcPrice - &GetMarcQuantity - - &GetAuthorisedValueDesc - &GetMarcStructure - &IsMarcStructureInternal - &GetMarcFromKohaField - &GetMarcSubfieldStructureFromKohaField - &GetFrameworkCode - &TransformKohaToMarc - &PrepHostMarcField - - &CountItemsIssued - &CountBiblioInOrders - ); - - # To modify something - push @EXPORT, qw( - &ModBiblio - &ModZebra - &UpdateTotalIssues - &RemoveAllNsb - ); - - # To delete something - push @EXPORT, qw( - &DelBiblio - ); - - # To link headings in a bib record - # to authority records. - push @EXPORT, qw( - &BiblioAutoLink - &LinkBibHeadingsToAuthorities - ); - - # Internal functions - # those functions are exported but should not be used - # they are useful in a few circumstances, so they are exported, - # but don't use them unless you are a core developer ;-) - push @EXPORT, qw( - &ModBiblioMarc - ); - - # Others functions - push @EXPORT, qw( - &TransformMarcToKoha - &TransformHtmlToMarc - &TransformHtmlToXml - prepare_host_field - ); -} =head1 NAME @@ -743,7 +716,7 @@ sub GetISBDView { my $framework = $params->{framework}; my $itemtype = $framework; my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); - my $tagslib = &GetMarcStructure( 1, $itemtype, { unsafe => 1 } ); + my $tagslib = GetMarcStructure( 1, $itemtype, { unsafe => 1 } ); my $ISBD = C4::Context->preference($sysprefname); my $bloc = $ISBD; diff --git a/C4/Items.pm b/C4/Items.pm index 3f683750d9..546d6981e7 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -21,77 +21,67 @@ package C4::Items; use strict; #use warnings; FIXME - Bug 2505 -use Carp; -use C4::Context; -use C4::Koha; -use C4::Biblio; -use Koha::DateUtils; -use MARC::Record; -use C4::ClassSource; -use C4::Log; -use List::MoreUtils qw/any/; -use YAML qw/Load/; -use DateTime::Format::MySQL; -use Data::Dumper; # used as part of logging item record changes, not just for - # debugging; so please don't remove this - -use Koha::AuthorisedValues; -use Koha::DateUtils qw/dt_from_string/; -use Koha::Database; - -use Koha::Biblioitems; -use Koha::Items; -use Koha::ItemTypes; -use Koha::SearchEngine; -use Koha::SearchEngine::Search; -use Koha::Libraries; - use vars qw(@ISA @EXPORT); - BEGIN { + require Exporter; + @ISA = qw(Exporter); - require Exporter; - @ISA = qw( Exporter ); - - # function exports @EXPORT = qw( GetItem AddItemFromMarc AddItem AddItemBatchFromMarc ModItemFromMarc - Item2Marc + Item2Marc ModItem ModDateLastSeen ModItemTransfer DelItem - CheckItemPreSave - GetItemsForInventory GetItemsInfo - GetItemsLocationInfo - GetHostItemsInfo - get_hostitemnumbers_of + GetItemsLocationInfo + GetHostItemsInfo + get_hostitemnumbers_of GetHiddenItemnumbers ItemSafeToDelete DelItemCheck - MoveItemFromBiblio - GetLatestAcquisitions - + MoveItemFromBiblio + GetLatestAcquisitions CartToShelf ShelfToCart - - GetAnalyticsCount - + GetAnalyticsCount SearchItemsByField SearchItems - PrepareItemrecordDisplay - ); } +use Carp; +use C4::Context; +use C4::Koha; +use C4::Biblio; +use Koha::DateUtils; +use MARC::Record; +use C4::ClassSource; +use C4::Log; +use List::MoreUtils qw(any); +use YAML qw(Load); +use DateTime::Format::MySQL; +use Data::Dumper; # used as part of logging item record changes, not just for + # debugging; so please don't remove this + +use Koha::AuthorisedValues; +use Koha::DateUtils qw(dt_from_string); +use Koha::Database; + +use Koha::Biblioitems; +use Koha::Items; +use Koha::ItemTypes; +use Koha::SearchEngine; +use Koha::SearchEngine::Search; +use Koha::Libraries; + =head1 NAME C4::Items - item management functions @@ -233,10 +223,10 @@ sub AddItemFromMarc { # parse item hash from MARC 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)); - my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items'); + + my $localitemmarc=MARC::Record->new; + $localitemmarc->append_fields($source_item_marc->field($itemtag)); + my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items'); my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode); return AddItem($item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields); } @@ -498,7 +488,7 @@ sub ModItemFromMarc { my $localitemmarc = MARC::Record->new; $localitemmarc->append_fields( $item_marc->field($itemtag) ); - my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); + my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); my $default_values = _build_default_values_for_mod_marc(); foreach my $item_field ( keys %$default_values ) { $item->{$item_field} = $default_values->{$item_field} @@ -2452,7 +2442,7 @@ sub PrepareItemrecordDisplay { # Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is # a shared data structure. No plugin (including custom ones) should change # its contents. See also GetMarcStructure. - my $tagslib = &GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } ); + my $tagslib = GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } ); # return nothing if we don't have found an existing framework. return q{} unless $tagslib; -- 2.11.0