From 9e1c4dfcb63fcc8e8e58c483d5788e92daa88799 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 21 Jan 2022 11:03:15 +0100 Subject: [PATCH] Bug 29697: Replace GetMarcBiblio occurrences with $biblio->metadata->record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel de Rooy JD Amended patch: -# FIXME Special case here - print "Biblio not found\n,"; + print "Biblio not found\n"; - my $biblio = Koha::Biblio->find($hostbiblionumber); + my $biblio = Koha::Biblios->find($hostbiblionumber); Rebased-by: Joonas Kylmälä --- C4/AuthoritiesMarc.pm | 7 ++-- C4/Biblio.pm | 29 ++++++++------- C4/Items.pm | 4 ++- C4/Labels/Label.pm | 9 +++-- C4/Serials.pm | 5 +-- C4/ShelfBrowser.pm | 4 +-- Koha/BackgroundJob/BatchUpdateBiblio.pm | 4 ++- Koha/Exporter/Record.pm | 4 ++- Koha/UI/Form/Builder/Item.pm | 8 +++-- acqui/neworderempty.pl | 5 +-- basket/basket.pl | 3 +- catalogue/labeledMARCdetail.pl | 5 ++- catalogue/moredetail.pl | 9 +++-- catalogue/showmarc.pl | 6 ++-- cataloguing/addbiblio.pl | 11 +++--- cataloguing/additem.pl | 4 +-- cataloguing/linkitem.pl | 14 ++++---- cataloguing/merge.pl | 12 ++++--- .../value_builder/marc21_linking_section.pl | 6 ++-- .../value_builder/unimarc_field_4XX.pl | 6 ++-- misc/add_date_fields_to_marc_records.pl | 5 +-- misc/batchRepairMissingBiblionumbers.pl | 6 ++-- misc/cronjobs/check-url-quick.pl | 5 +-- misc/link_bibs_to_authorities.pl | 13 +++---- ...MARC_sync_date_created_with_marc_biblio.pl | 8 +++-- .../process_record_through_filter.pl | 9 +++-- .../remove_items_from_biblioitems.pl | 8 +++-- misc/maintenance/sanitize_records.pl | 8 ++++- misc/maintenance/touch_all_biblios.pl | 8 +++-- .../22_to_30/missing090field.pl | 6 ++-- .../22_to_30/rebuild_unimarc_100.pl | 6 ++-- misc/migration_tools/buildEDITORS.pl | 5 +-- misc/migration_tools/create_analytical_rel.pl | 12 ++++--- misc/migration_tools/import_lexile.pl | 5 +-- .../switch_marc21_series_info.pl | 6 ++-- misc/migration_tools/upgradeitems.pl | 5 +-- opac/opac-basket.pl | 3 +- opac/opac-reserve.pl | 10 +++--- opac/opac-shelves.pl | 11 +++--- opac/opac-showreviews.pl | 4 +-- opac/tracklinks.pl | 4 ++- t/db_dependent/Authority/Merge.t | 35 ++++++++++--------- tools/batch_delete_records.pl | 4 +-- virtualshelves/shelves.pl | 5 ++- 44 files changed, 204 insertions(+), 142 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index ef90a41cf0..e211af2b94 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -23,7 +23,7 @@ use warnings; use MARC::Field; use C4::Context; -use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblio ); +use C4::Biblio qw( GetFrameworkCode ModBiblio ); use C4::Search qw( FindDuplicate new_record_from_zebra ); use C4::AuthoritiesMarc::MARC21; use C4::AuthoritiesMarc::UNIMARC; @@ -1463,8 +1463,9 @@ sub merge { my $counteditedbiblio = 0; foreach my $biblionumber ( @biblionumbers ) { - my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber }); - next if !$marcrecord; + my $biblio = Koha::Biblios->find($biblionumber); + next unless $biblio; + my $marcrecord = $biblio->metadata->record; my $update = 0; foreach my $tagfield (@$tags_using_authtype) { my $countfrom = 0; # used in strict mode to remove duplicates diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 41346511e7..491201a5af 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -364,8 +364,8 @@ sub ModBiblio { } if ( C4::Context->preference("CataloguingLog") ) { - my $newrecord = GetMarcBiblio({ biblionumber => $biblionumber }); - logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $newrecord->as_formatted ); + my $biblio = Koha::Biblios->find($biblionumber); + logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $biblio->metadata->record->as_formatted ); } if ( !$options->{disable_autolink} && C4::Context->preference('BiblioAddsAuthorities') ) { @@ -1948,8 +1948,9 @@ This function returns a host field populated with data from the host record, the sub PrepHostMarcField { my ($hostbiblionumber,$hostitemnumber, $marcflavour) = @_; $marcflavour ||="MARC21"; - - my $hostrecord = GetMarcBiblio({ biblionumber => $hostbiblionumber }); + + my $biblio = Koha::Biblios->find($hostbiblionumber); + my $hostrecord = $biblio->metadata->record; my $item = Koha::Items->find($hostitemnumber); my $hostmarcfield; @@ -2952,7 +2953,9 @@ Generate the host item entry for an analytic child entry sub prepare_host_field { my ( $hostbiblio, $marcflavour ) = @_; $marcflavour ||= C4::Context->preference('marcflavour'); - my $host = GetMarcBiblio({ biblionumber => $hostbiblio }); + + my $biblio = Koha::Biblios->find($hostbiblio); + my $host = $biblio->metadata->record; # unfortunately as_string does not 'do the right thing' # if field returns undef my %sfd; @@ -3090,16 +3093,17 @@ sub UpdateTotalIssues { my ($biblionumber, $increase, $value, $skip_holds_queue) = @_; my $totalissues; - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); - unless ($record) { - carp "UpdateTotalIssues could not get biblio record"; - return; - } - my $biblio = Koha::Biblios->find( $biblionumber ); + my $biblio = Koha::Biblios->find($biblionumber); unless ($biblio) { carp "UpdateTotalIssues could not get datas of biblio"; return; } + + my $record = $biblio->metadata->record; + unless ($record) { + carp "UpdateTotalIssues could not get biblio record"; + return; + } my $biblioitem = $biblio->biblioitem; my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' ); unless ($totalissuestag) { @@ -3223,7 +3227,8 @@ sub ApplyMarcOverlayRules { carp 'ApplyMarcOverlayRules called on undefined record'; return; } - my $old_record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $old_record = $biblio->metadata->record; # Skip overlay rules if called with no context if ($old_record && defined $params->{overlay_context}) { diff --git a/C4/Items.pm b/C4/Items.pm index 301fb51ebe..2af1ee29f9 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -64,6 +64,7 @@ use Koha::AuthorisedValues; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Database; +use Koha::Biblios; use Koha::Biblioitems; use Koha::Items; use Koha::ItemTypes; @@ -948,7 +949,8 @@ sub get_hostitemnumbers_of { return (); } - my $marcrecord = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $marcrecord = $biblio->metadata->record; return unless $marcrecord; my ( @returnhostitemnumbers, $tag, $biblio_s, $item_s ); diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index 5f3a610079..eadf9cce0a 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -9,7 +9,8 @@ use Text::CSV_XS; use Text::Bidi qw( log2vis ); use C4::Context; -use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ); +use C4::Biblio qw( GetMarcFromKohaField ); +use Koha::Biblios; use Koha::ClassSources; use Koha::ClassSortRules; use Koha::ClassSplitRules; @@ -337,7 +338,8 @@ sub draw_label_text { my $font = $self->{'font'}; my $item = _get_label_item($self->{'item_number'}); my $label_fields = _get_text_fields($self->{'format_string'}); - my $record = GetMarcBiblio({ biblionumber => $item->{'biblionumber'} }); + my $biblio = Koha::Biblios->find($item->{biblionumber}); + my $record = $biblio->metadata->record; # FIXME - returns all items, so you can't get data from an embedded holdings field. # TODO - add a GetMarcBiblio1item(bibnum,itemnum) or a GetMarcItem(itemnum). my $cn_source = ($item->{'cn_source'} ? $item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource')); @@ -554,7 +556,8 @@ sub csv_data { my $self = shift; my $label_fields = _get_text_fields($self->{'format_string'}); my $item = _get_label_item($self->{'item_number'}); - my $bib_record = GetMarcBiblio({ biblionumber => $item->{biblionumber} }); + my $biblio = Koha::Biblios->find($item->{biblionumber}); + my $bib_record = $biblio->metadata->record; my @csv_data = (map { _get_barcode_data($_->{'code'},$item,$bib_record) } @$label_fields); return \@csv_data; } diff --git a/C4/Serials.pm b/C4/Serials.pm index 93c8a759d9..c6b2ba7719 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -32,11 +32,12 @@ use Date::Calc qw( Today ); use POSIX qw( strftime ); -use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ModBiblio ); +use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); use C4::Log qw( logaction ); # logaction use C4::Serials::Frequency qw( GetSubscriptionFrequency ); use C4::Serials::Numberpattern; use Koha::AdditionalFieldValues; +use Koha::Biblios; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Serial; use Koha::Subscriptions; @@ -1497,7 +1498,7 @@ sub NewSubscription { #set serial flag on biblio if not already set. my $biblio = Koha::Biblios->find( $biblionumber ); if ( $biblio and !$biblio->serial ) { - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $record = $biblio->metadata->record; my ( $tag, $subf ) = GetMarcFromKohaField( 'biblio.serial' ); if ($tag) { eval { $record->field($tag)->update( $subf => 1 ); }; diff --git a/C4/ShelfBrowser.pm b/C4/ShelfBrowser.pm index 0b1bec414d..5c9159d002 100644 --- a/C4/ShelfBrowser.pm +++ b/C4/ShelfBrowser.pm @@ -20,7 +20,7 @@ package C4::ShelfBrowser; use strict; use warnings; -use C4::Biblio qw( GetAuthorisedValueDesc GetMarcBiblio ); +use C4::Biblio qw( GetAuthorisedValueDesc ); use C4::Context; use C4::Koha qw( GetNormalizedUPC GetNormalizedOCLCNumber GetNormalizedISBN GetNormalizedEAN ); use Koha::Biblios; @@ -226,7 +226,7 @@ sub GetShelfInfo { $item->{medium} = $biblio->medium; $item->{part_number} = $biblio->part_number; $item->{part_name} = $biblio->part_name; - my $this_record = GetMarcBiblio({ biblionumber => $biblio->biblionumber }); + my $this_record = $biblio->metadata->record; $item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour); $item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour); $item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour); diff --git a/Koha/BackgroundJob/BatchUpdateBiblio.pm b/Koha/BackgroundJob/BatchUpdateBiblio.pm index 35152e4526..63d1277ff4 100644 --- a/Koha/BackgroundJob/BatchUpdateBiblio.pm +++ b/Koha/BackgroundJob/BatchUpdateBiblio.pm @@ -18,6 +18,7 @@ package Koha::BackgroundJob::BatchUpdateBiblio; use Modern::Perl; use JSON qw( decode_json encode_json ); +use Koha::Biblios; use Koha::DateUtils qw( dt_from_string ); use Koha::Virtualshelves; use Koha::SearchEngine; @@ -87,7 +88,8 @@ sub process { # Modify the biblio my $error = eval { - my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; C4::MarcModificationTemplates::ModifyRecordWithTemplate( $mmtid, $record ); my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, { diff --git a/Koha/Exporter/Record.pm b/Koha/Exporter/Record.pm index 05cfe3e2a7..1716e9c9a1 100644 --- a/Koha/Exporter/Record.pm +++ b/Koha/Exporter/Record.pm @@ -7,6 +7,7 @@ use MARC::File::USMARC; use C4::AuthoritiesMarc; use C4::Biblio qw( GetMarcFromKohaField ); use C4::Record; +use Koha::Biblios; use Koha::CsvProfiles; use Koha::Logger; use List::Util qw( all any ); @@ -120,7 +121,8 @@ sub _get_biblio_for_export { my $export_items = $params->{export_items} // 1; my $only_export_items_for_branches = $params->{only_export_items_for_branches}; - my $record = eval { C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); }; + my $biblio = Koha::Biblios->find($biblionumber); + my $record = eval { $biblio->metadata->record }; return if $@ or not defined $record; diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm index 5efe6ed796..2985b37bf6 100644 --- a/Koha/UI/Form/Builder/Item.pm +++ b/Koha/UI/Form/Builder/Item.pm @@ -18,10 +18,11 @@ package Koha::UI::Form::Builder::Item; use Modern::Perl; use MARC::Record; use C4::Context; -use C4::Biblio qw( GetFrameworkCode GetMarcBiblio GetMarcStructure IsMarcStructureInternal ); +use C4::Biblio qw( GetFrameworkCode GetMarcStructure IsMarcStructureInternal ); use C4::Koha qw( GetAuthorisedValues ); use C4::ClassSource qw( GetClassSources ); +use Koha::Biblios; use Koha::DateUtils qw( dt_from_string ); use Koha::Libraries; @@ -484,8 +485,9 @@ sub edit_form { : undef; my $biblionumber = $self->{biblionumber}; - my $frameworkcode = $biblionumber ? GetFrameworkCode($biblionumber) : q{}; - my $marc_record = $biblionumber ? GetMarcBiblio( { biblionumber => $biblionumber } ) : undef; + my $biblio = Koha::Biblios->find($biblionumber); + my $frameworkcode = $biblio ? GetFrameworkCode($biblionumber) : q{}; + my $marc_record = $biblio ? $biblio->metadata->record : undef; my @subfields; my $tagslib = GetMarcStructure( 1, $frameworkcode ); foreach my $tag ( keys %{$tagslib} ) { diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 7c443147b1..182a04eccb 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -77,7 +77,6 @@ use C4::Suggestions qw( GetSuggestion GetSuggestionInfo ); use C4::Biblio qw( AddBiblio GetBiblioData - GetMarcBiblio GetMarcFromKohaField GetMarcPrice GetMarcStructure @@ -92,6 +91,7 @@ use C4::ImportBatch qw( SetImportRecordStatus SetMatchedBiblionumber GetImportRe use Koha::Acquisition::Booksellers; use Koha::Acquisition::Currencies qw( get_active ); +use Koha::Biblios; use Koha::BiblioFrameworks; use Koha::DateUtils qw( dt_from_string ); use Koha::MarcSubfieldStructures; @@ -296,7 +296,8 @@ $biblionumber = $data->{biblionumber}; # - no ordernumber, no biblionumber: from a suggestion, from a new order if ( not $ordernumber or $biblionumber ) { if ( C4::Context->preference('UseACQFrameworkForBiblioRecords') ) { - my $record = $biblionumber ? GetMarcBiblio({ biblionumber => $biblionumber }) : undef; + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio ? $biblio->metadata->record : undef; foreach my $tag ( sort keys %{$tagslib} ) { next if $tag eq ''; next if $tag eq $itemnumber_tag; # skip items fields diff --git a/basket/basket.pl b/basket/basket.pl index fdcc2c8559..6f93e5a82b 100755 --- a/basket/basket.pl +++ b/basket/basket.pl @@ -20,7 +20,6 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Koha; use C4::Biblio qw( - GetMarcBiblio GetMarcSeries GetMarcSubjects GetMarcUrls @@ -67,7 +66,7 @@ foreach my $biblionumber ( @bibs ) { my $biblio = Koha::Biblios->find( $biblionumber ) or next; my $dat = $biblio->unblessed; - my $record = &GetMarcBiblio({ biblionumber => $biblionumber }); + my $record = $biblio->metadata->record; my $marcnotesarray = $biblio->get_marc_notes; my $marcauthorsarray = $biblio->get_marc_authors; my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl index 6418fd0edc..86525162f4 100755 --- a/catalogue/labeledMARCdetail.pl +++ b/catalogue/labeledMARCdetail.pl @@ -26,7 +26,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Biblio qw( GetBiblioData GetFrameworkCode - GetMarcBiblio GetMarcStructure ); use C4::Search qw( z3950_search_args enabled_staff_search_views ); @@ -56,7 +55,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my $record = GetMarcBiblio({ biblionumber => $biblionumber }); +my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio +my $record = $biblio_object->metadata->record; if ( not defined $record ) { # biblionumber invalid -> report and exit $template->param( unknownbiblionumber => 1, @@ -66,7 +66,6 @@ if ( not defined $record ) { exit; } -my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio my $tagslib = GetMarcStructure(1,$frameworkcode); my $biblio = GetBiblioData($biblionumber); diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index b0dc6e4206..834678ec3c 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -23,7 +23,7 @@ use Modern::Perl; use C4::Koha qw( GetAuthorisedValues ); use CGI qw ( -utf8 ); use HTML::Entities; -use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio ); +use C4::Biblio qw( GetBiblioData GetFrameworkCode ); use C4::Items qw( GetHostItemsInfo GetItemsInfo ); use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice ); use C4::Output qw( output_and_exit output_html_with_http_headers ); @@ -113,10 +113,11 @@ for my $itm (@all_items) { ($itemnumber != $itm->{itemnumber})); } -my $record=GetMarcBiblio({ biblionumber => $biblionumber }); +my $biblio = Koha::Biblios->find( $biblionumber ); +my $record = $biblio ? $biblio->metadata->record : undef; output_and_exit( $query, $cookie, $template, 'unknown_biblio') - unless $record; + unless $biblio && $record; my $hostrecords; # adding items linked via host biblios @@ -126,8 +127,6 @@ if (@hostitems){ push (@items,@hostitems); } -my $biblio = Koha::Biblios->find( $biblionumber ); - my $totalcount=@all_items; my $showncount=@items; my $hiddencount = $totalcount - $showncount; diff --git a/catalogue/showmarc.pl b/catalogue/showmarc.pl index 8a9f0e9bad..207710fded 100755 --- a/catalogue/showmarc.pl +++ b/catalogue/showmarc.pl @@ -30,9 +30,10 @@ use Encode; use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); -use C4::Biblio qw( GetMarcBiblio GetXmlBiblio ); +use C4::Biblio qw( GetXmlBiblio ); use C4::XSLT; +use Koha::Biblios; use Koha::Import::Records; my $input= CGI->new; @@ -65,7 +66,8 @@ if ($importid) { } } else { - $record =GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + $record = $biblio->metadata->record; } if(!ref $record) { print $input->redirect("/cgi-bin/koha/errors/404.pl"); diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 036764417c..92abe81082 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -28,7 +28,6 @@ use C4::Biblio qw( AddBiblio DelBiblio GetFrameworkCode - GetMarcBiblio GetMarcFromKohaField GetMarcStructure GetUsedMarcStructure @@ -47,6 +46,7 @@ use C4::Charset qw( SetMarcUnicodeFlag ); use Koha::BiblioFrameworks; use Koha::DateUtils qw( dt_from_string ); +use Koha::Biblios; use Koha::ItemTypes; use Koha::Libraries; @@ -749,9 +749,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $biblio; if ($biblionumber){ - my $does_bib_exist = Koha::Biblios->find($biblionumber); - if (!defined $does_bib_exist){ + $biblio = Koha::Biblios->find($biblionumber); + unless ( $biblio ) { $biblionumber = undef; $template->param( bib_doesnt_exist => 1 ); } @@ -800,8 +801,8 @@ my ( $biblioitemnumber ); -if (($biblionumber) && !($breedingid)){ - $record = GetMarcBiblio({ biblionumber => $biblionumber }); +if ( $biblio && !$breedingid ) { + $record = $biblio->metadata->record; } if ($breedingid) { ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 7cf5c03660..527b510055 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -26,7 +26,6 @@ use C4::Auth qw( get_template_and_user haspermission ); use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); use C4::Biblio qw( GetFrameworkCode - GetMarcBiblio GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal @@ -37,6 +36,7 @@ use C4::Circulation qw( barcodedecode LostItem ); use C4::Barcodes; use C4::Barcodes::ValueBuilder; use Koha::DateUtils qw( dt_from_string ); +use Koha::Biblios; use Koha::Items; use Koha::ItemTypes; use Koha::Items; @@ -163,7 +163,7 @@ $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibra $restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'})); our $tagslib = &GetMarcStructure(1,$frameworkcode); -my $record = GetMarcBiblio({ biblionumber => $biblionumber }); +my $record = $biblio->metadata->record; output_and_exit_if_error( $input, $cookie, $template, { module => 'cataloguing', record => $record } ); diff --git a/cataloguing/linkitem.pl b/cataloguing/linkitem.pl index cea6551996..0acaf6f64b 100755 --- a/cataloguing/linkitem.pl +++ b/cataloguing/linkitem.pl @@ -24,8 +24,9 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); -use C4::Biblio qw( GetMarcBiblio ModBiblio PrepHostMarcField ); +use C4::Biblio qw( ModBiblio PrepHostMarcField ); use C4::Context; +use Koha::Biblios; my $query = CGI->new; @@ -42,13 +43,14 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( } ); -my $biblio = GetMarcBiblio({ biblionumber => $biblionumber }); +my $biblio = Koha::Biblios->find($biblionumber); +my $record = $biblio->metadata->record; my $marcflavour = C4::Context->preference("marcflavour"); $marcflavour ||="MARC21"; if ($marcflavour eq 'MARC21') { - $template->param(bibliotitle => $biblio->subfield('245','a')); + $template->param(bibliotitle => $record->subfield('245','a')); } elsif ($marcflavour eq 'UNIMARC') { - $template->param(bibliotitle => $biblio->subfield('200','a')); + $template->param(bibliotitle => $record->subfield('200','a')); } $template->param(biblionumber => $biblionumber); @@ -59,9 +61,9 @@ if ( $barcode && $biblionumber ) { if ($item) { my $field = PrepHostMarcField( $item->biblio->biblionumber, $item->itemnumber, $marcflavour ); - $biblio->append_fields($field); + $record->append_fields($field); - my $modresult = ModBiblio( $biblio, $biblionumber, '' ); + my $modresult = ModBiblio( $record, $biblionumber, '' ); if ($modresult) { $template->param( success => 1 ); } diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl index fca94ca4d5..7fe218845e 100755 --- a/cataloguing/merge.pl +++ b/cataloguing/merge.pl @@ -27,7 +27,6 @@ use C4::Biblio qw( DelBiblio GetBiblioData GetFrameworkCode - GetMarcBiblio GetMarcFromKohaField GetMarcStructure ModBiblio @@ -85,7 +84,8 @@ if ($merge) { } # Rewriting the leader - $record->leader(GetMarcBiblio({ biblionumber => $ref_biblionumber })->leader()); + my $biblio = Koha::Biblios->find($ref_biblionumber); + $record->leader($biblio->metadata->record->leader()); my $frameworkcode = $input->param('frameworkcode'); @@ -93,7 +93,7 @@ if ($merge) { ModBiblio($record, $ref_biblionumber, $frameworkcode); # Moving items and article requests from the other record to the reference record - my $biblio = Koha::Biblios->find($ref_biblionumber); + $biblio = $biblio->get_from_storage; foreach my $biblionumber (@biblionumbers) { my $from_biblio = Koha::Biblios->find($biblionumber); $from_biblio->items->move_to_biblio($biblio); @@ -116,7 +116,8 @@ if ($merge) { my $report_header = {}; foreach my $biblionumber ($ref_biblionumber, @biblionumbers) { # build report - my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $marcrecord = $biblio->metadata->record; my %report_record = ( biblionumber => $biblionumber, fields => {}, @@ -204,7 +205,8 @@ if ($merge) { # Creating a loop for display my @records; foreach my $biblionumber (@biblionumbers) { - my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $marcrecord = $biblio->metadata->record; my $frameworkcode = GetFrameworkCode($biblionumber); my $recordObj = Koha::MetadataRecord->new({'record' => $marcrecord, schema => $marcflavour}); my $record = { diff --git a/cataloguing/value_builder/marc21_linking_section.pl b/cataloguing/value_builder/marc21_linking_section.pl index 7a7478642e..04d7d342e3 100755 --- a/cataloguing/value_builder/marc21_linking_section.pl +++ b/cataloguing/value_builder/marc21_linking_section.pl @@ -28,8 +28,9 @@ use C4::Search qw( new_record_from_zebra ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); -use C4::Biblio qw( GetMarcBiblio TransformMarcToKoha ); +use C4::Biblio qw( TransformMarcToKoha ); +use Koha::Biblios; use Koha::ItemTypes; use Koha::SearchEngine; @@ -81,7 +82,8 @@ my $launcher = sub { ); #get marc record - $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + $marcrecord = $biblio->metadata->record; my $subfield_value_9 = $biblionumber; my $subfield_value_0 = $biblionumber; diff --git a/cataloguing/value_builder/unimarc_field_4XX.pl b/cataloguing/value_builder/unimarc_field_4XX.pl index 2d027101fe..7b0ef28018 100755 --- a/cataloguing/value_builder/unimarc_field_4XX.pl +++ b/cataloguing/value_builder/unimarc_field_4XX.pl @@ -28,8 +28,9 @@ use C4::Search qw( new_record_from_zebra ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); -use C4::Biblio qw( GetMarcBiblio TransformMarcToKoha ); +use C4::Biblio qw( TransformMarcToKoha ); +use Koha::Biblios; use Koha::ItemTypes; use Koha::SearchEngine; @@ -92,7 +93,8 @@ sub plugin { ); #get marc record - $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + $marcrecord = $biblio->metadata->record; my $subfield_value_9 = $biblionumber; my $subfield_value_0; diff --git a/misc/add_date_fields_to_marc_records.pl b/misc/add_date_fields_to_marc_records.pl index c310350b6a..40b9fa38da 100755 --- a/misc/add_date_fields_to_marc_records.pl +++ b/misc/add_date_fields_to_marc_records.pl @@ -24,6 +24,7 @@ use Pod::Usage qw( pod2usage ); use MARC::Field; use C4::Biblio; +use Koha::Biblios; use Koha::DateUtils qw( dt_from_string ); my ( $verbose, $help, $confirm, $where, @fields, $unless_exists_field ); @@ -62,8 +63,8 @@ my $sth = $sth->execute(); while ( my ( $biblionumber, $frameworkcode ) = $sth->fetchrow_array ) { - my $marc_record = - C4::Biblio::GetMarcBiblio( { biblionumber => $biblionumber } ); + my $biblio = Koha::Biblios->find($biblionumber); + my $marc_record = $biblio->metadata->record; next unless $marc_record; if ( $unless_exists_field ) { my ( $tag, $subfield ) = split '\$', $unless_exists_field; diff --git a/misc/batchRepairMissingBiblionumbers.pl b/misc/batchRepairMissingBiblionumbers.pl index 5a2d31fd30..97d619c362 100755 --- a/misc/batchRepairMissingBiblionumbers.pl +++ b/misc/batchRepairMissingBiblionumbers.pl @@ -8,7 +8,8 @@ use warnings; # Koha modules used use Koha::Script; use C4::Context; -use C4::Biblio qw( GetMarcBiblio ModBiblioMarc ); +use C4::Biblio qw( ModBiblioMarc ); +use Koha::Biblios; my $dbh = C4::Context->dbh; @@ -17,7 +18,8 @@ my $sth=$dbh->prepare("SELECT biblio.biblionumber, biblioitemnumber, frameworkco $sth->execute(); while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){ - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber); my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber )}; if($@){ diff --git a/misc/cronjobs/check-url-quick.pl b/misc/cronjobs/check-url-quick.pl index b9108a6364..6826d79426 100755 --- a/misc/cronjobs/check-url-quick.pl +++ b/misc/cronjobs/check-url-quick.pl @@ -23,7 +23,7 @@ use Getopt::Long qw( GetOptions ); use Koha::Script -cron; use C4::Context; -use C4::Biblio qw( GetMarcBiblio ); +use Koha::Biblios; use AnyEvent; use AnyEvent::HTTP qw( http_request ); use Encode qw( encode_utf8 ); @@ -93,7 +93,8 @@ sub check_all_url { cb => sub { return if $count > $maxconn; while ( my ($biblionumber) = $sth->fetchrow ) { - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; for my $tag (@tags) { foreach my $field ( $record->field($tag) ) { my $url = $field->subfield('u'); diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl index 8de9b683a6..9a095454cb 100755 --- a/misc/link_bibs_to_authorities.pl +++ b/misc/link_bibs_to_authorities.pl @@ -7,10 +7,10 @@ use Koha::Script; use C4::Context; use C4::Biblio qw( GetFrameworkCode - GetMarcBiblio LinkBibHeadingsToAuthorities ModBiblio ); +use Koha::Biblios; use Getopt::Long qw( GetOptions ); use Pod::Usage qw( pod2usage ); use Time::HiRes qw( time ); @@ -192,8 +192,9 @@ sub process_bib { my $args = shift; my $tagtolink = $args->{tagtolink}; my $allowrelink = $args->{allowrelink}; - my $bib = GetMarcBiblio({ biblionumber => $biblionumber }); - unless ( defined $bib ) { + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; + unless ( defined $record ) { print "\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n"; $num_bad_bibs++; @@ -203,7 +204,7 @@ sub process_bib { my $frameworkcode = GetFrameworkCode($biblionumber); my ( $headings_changed, $results ) = - LinkBibHeadingsToAuthorities( $linker, $bib, $frameworkcode, $allowrelink, $tagtolink ); + LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode, $allowrelink, $tagtolink ); foreach my $key ( keys %{ $results->{'unlinked'} } ) { $unlinked_headings{$key} += $results->{'unlinked'}->{$key}; } @@ -216,7 +217,7 @@ sub process_bib { if ($headings_changed) { if ($verbose) { - my $title = substr( $bib->title, 0, 20 ); + my $title = substr( $record->title, 0, 20 ); printf( "Bib %12d (%-20s): %3d headings changed\n", $biblionumber, @@ -225,7 +226,7 @@ sub process_bib { ); } if ( not $test_only ) { - ModBiblio( $bib, $biblionumber, $frameworkcode, { disable_autolink => 1 }); + ModBiblio( $record, $biblionumber, $frameworkcode, { disable_autolink => 1 }); #Last param is to note ModBiblio was called from linking script and bib should not be linked again $num_bibs_modified++; } diff --git a/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl b/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl index c787374eef..11543f36a3 100755 --- a/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl +++ b/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl @@ -8,7 +8,8 @@ use strict; use warnings; use Koha::Script; -use C4::Biblio qw( GetMarcBiblio ModBiblio ); +use C4::Biblio qw( ModBiblio ); +use Koha::Biblios; use Getopt::Long qw( GetOptions ); sub _read_marc_code { @@ -83,10 +84,11 @@ my $sth_prepared; sub updateMarc { my $id = shift; - my $biblio = GetMarcBiblio({ biblionumber => $id }); + my $biblio = Koha::Biblios->find($id); + $biblio &&= $biblio->metadata->record; unless ($biblio) { - $debug and warn '[ERROR] GetMarcBiblio did not return any biblio.'; + $debug and warn '[ERROR] Biblio not found.'; return; } diff --git a/misc/maintenance/process_record_through_filter.pl b/misc/maintenance/process_record_through_filter.pl index 8259e31566..14aa9d4ef1 100755 --- a/misc/maintenance/process_record_through_filter.pl +++ b/misc/maintenance/process_record_through_filter.pl @@ -8,10 +8,15 @@ use strict; use warnings; use Koha::Script; +use Koha::Biblios; use Koha::RecordProcessor; -use C4::Biblio qw( GetMarcBiblio ); -my $record = GetMarcBiblio({ biblionumber => $ARGV[0] }); +my $biblio = Koha::Biblios->find($ARGV[0]); +unless ( $biblio ) { + print "Biblio not found\n"; + exit; +} +my $record = $biblio->metadata->record; print "Before: " . $record->as_formatted() . "\n"; my $processor = Koha::RecordProcessor->new( { filters => ( $ARGV[1] ) }); diff --git a/misc/maintenance/remove_items_from_biblioitems.pl b/misc/maintenance/remove_items_from_biblioitems.pl index 029e1e9ef0..82d729481b 100755 --- a/misc/maintenance/remove_items_from_biblioitems.pl +++ b/misc/maintenance/remove_items_from_biblioitems.pl @@ -24,7 +24,8 @@ $|=1; use Koha::Script; use C4::Context; -use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblio ); +use C4::Biblio qw( GetFrameworkCode ModBiblio ); +use Koha::Biblios; use Getopt::Long qw( GetOptions ); my ($wherestring, $run, $silent, $want_help); @@ -50,8 +51,9 @@ while (my $biblionumber = $query->fetchrow){ $count++; print "." unless $silent; print "\r$count" unless ($silent or ($count % 100)); - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); - + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; + if ($record) { ModBiblio($record, $biblionumber, GetFrameworkCode($biblionumber)) ; } diff --git a/misc/maintenance/sanitize_records.pl b/misc/maintenance/sanitize_records.pl index 2aa9f02a3f..430d89d6a7 100755 --- a/misc/maintenance/sanitize_records.pl +++ b/misc/maintenance/sanitize_records.pl @@ -23,6 +23,7 @@ use Koha::Script; use C4::Charset; use C4::Context; use C4::Biblio; +use Koha::Biblios; use Getopt::Long qw( GetOptions ); use Pod::Usage qw( pod2usage ); @@ -109,7 +110,12 @@ for my $biblionumber (@biblionumbers) { say " skipping. ERROR: Invalid biblionumber." if $verbose; next; } - my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + unless ( $biblio ) { + say " skipping. ERROR: biblionumber not found." if $verbose; + next; + } + my $record = $biblio->metadata->record; unless ($record) { say " skipping. ERROR: Invalid record." if $verbose; next; diff --git a/misc/maintenance/touch_all_biblios.pl b/misc/maintenance/touch_all_biblios.pl index c2259602b4..956b7677ad 100755 --- a/misc/maintenance/touch_all_biblios.pl +++ b/misc/maintenance/touch_all_biblios.pl @@ -25,7 +25,8 @@ use Getopt::Long qw( GetOptions ); use Koha::Script; use C4::Context; -use C4::Biblio qw( GetMarcBiblio ModBiblio ); +use C4::Biblio qw( ModBiblio ); +use Koha::Biblios; use Pod::Usage qw( pod2usage ); @@ -75,8 +76,9 @@ $sth1->execute(); # fetch info from the search while (my ($biblionumber, $frameworkcode) = $sth1->fetchrow_array){ - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); - + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; + my $modok = ModBiblio($record, $biblionumber, $frameworkcode); if ($modok) { diff --git a/misc/migration_tools/22_to_30/missing090field.pl b/misc/migration_tools/22_to_30/missing090field.pl index a75fb24ead..32a11e722a 100755 --- a/misc/migration_tools/22_to_30/missing090field.pl +++ b/misc/migration_tools/22_to_30/missing090field.pl @@ -8,7 +8,8 @@ use strict; # Koha modules used use C4::Context; -use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ModBiblioMarc ); +use C4::Biblio qw( GetMarcFromKohaField ModBiblioMarc ); +use Koha::Biblios; use MARC::File::USMARC; $|=1; @@ -19,7 +20,8 @@ $sth->execute(); my $i=1; while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){ - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; print "."; print "\r$i" unless $i %100; MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record); diff --git a/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl b/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl index b9c976d71f..b0c5dc50b7 100755 --- a/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl +++ b/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl @@ -8,7 +8,8 @@ use strict; # Koha modules used use C4::Context; -use C4::Biblio qw( GetMarcBiblio ModBiblioMarc ); +use C4::Biblio qw( ModBiblioMarc ); +use Koha::Biblios; use MARC::File::USMARC; @@ -22,7 +23,8 @@ print "Creating/updating field 100 if needed\n"; while (my ($biblionumber,$time)=$sth->fetchrow ){ # my $record; # print "record : $biblionumber \n"; - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio ? $biblio->metadata->record : undef; # print "=> ".$record->as_formatted; MARCmodrecord($biblionumber,$record,$time) if ($record); # diff --git a/misc/migration_tools/buildEDITORS.pl b/misc/migration_tools/buildEDITORS.pl index a6f1d8baa2..816b5892a0 100755 --- a/misc/migration_tools/buildEDITORS.pl +++ b/misc/migration_tools/buildEDITORS.pl @@ -10,8 +10,8 @@ use MARC::Record; use MARC::Batch; use Koha::Script; use C4::Context; -use C4::Biblio qw( GetMarcBiblio ); use C4::AuthoritiesMarc; +use Koha::Biblios; use Time::HiRes qw( gettimeofday ); use Getopt::Long qw( GetOptions ); @@ -70,7 +70,8 @@ my $i=1; my $counter; my %hash; while (my ($bibid) = $sth->fetchrow) { - my $record = GetMarcBiblio({ biblionumber => $bibid }); + my $biblio = Koha::Biblios->find($bibid); + my $record = $biblio->metadata->record; my $isbnField = $record->field('010'); next unless $isbnField; my $isbn=$isbnField->subfield('a'); diff --git a/misc/migration_tools/create_analytical_rel.pl b/misc/migration_tools/create_analytical_rel.pl index 370d92b0e8..1df2d55be2 100755 --- a/misc/migration_tools/create_analytical_rel.pl +++ b/misc/migration_tools/create_analytical_rel.pl @@ -5,8 +5,9 @@ use strict; use Koha::Script; use C4::Context; -use C4::Biblio qw( GetMarcBiblio ModBiblio ); +use C4::Biblio qw( ModBiblio ); use Koha::Items; +use Koha::Biblios; use Getopt::Long qw( GetOptions ); $| = 1; @@ -75,15 +76,16 @@ _SUMMARY_ sub process_bib { my $biblionumber = shift; - my $bib = GetMarcBiblio({ biblionumber => $biblionumber }); - unless (defined $bib) { + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; + unless (defined $record) { print "\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n"; $num_bad_bibs++; return; } #loop through each host field and populate subfield 0 and 9 my $analyticfield = '773'; - foreach my $hostfield ( $bib->field($analyticfield) ) { + foreach my $hostfield ( $record->field($analyticfield) ) { if(my $barcode = $hostfield->subfield('o')){ my $item = Koha::Items->find({ barcode => $barcode }); if ($item) { @@ -98,7 +100,7 @@ sub process_bib { } if ($modif) { $num_bibs_modified++; - my $modresult = ModBiblio( $bib, $biblionumber, '' ); + my $modresult = ModBiblio( $record, $biblionumber, '' ); warn "Modifying biblio $biblionumber"; if ( !$modresult ) { warn "Unable to modify biblio $biblionumber with update host field"; diff --git a/misc/migration_tools/import_lexile.pl b/misc/migration_tools/import_lexile.pl index 784b5826f0..0d506ccc0f 100755 --- a/misc/migration_tools/import_lexile.pl +++ b/misc/migration_tools/import_lexile.pl @@ -33,7 +33,7 @@ use Text::CSV; use Koha::Script; use C4::Context; -use C4::Biblio qw( GetMarcBiblio ModBiblio ); +use C4::Biblio qw( ModBiblio ); use C4::Koha qw( GetVariationsOfISBN ); use Koha::Biblios; @@ -145,7 +145,8 @@ while ( my $row = $csv->getline_hr($fh) ) { foreach my $biblionumber (@biblionumbers) { $counter++; - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; if ($verbose) { say "Found matching record! Biblionumber: $biblionumber"; diff --git a/misc/migration_tools/switch_marc21_series_info.pl b/misc/migration_tools/switch_marc21_series_info.pl index 39e0db1fdd..654b0f7d30 100755 --- a/misc/migration_tools/switch_marc21_series_info.pl +++ b/misc/migration_tools/switch_marc21_series_info.pl @@ -23,8 +23,9 @@ use warnings; # Script to switch the MARC21 440$anv and 490$av information use Koha::Script; -use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblioMarc ); +use C4::Biblio qw( GetFrameworkCode ModBiblioMarc ); use C4::Context; +use Koha::Biblios; use Getopt::Long qw( GetOptions ); my $commit; @@ -133,7 +134,8 @@ while ( my ( $biblionumber ) = $bibs_sth->fetchrow ) { my ( @newfields ); # Get biblio marc - my $biblio = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + $biblio &&= $biblio->metadata->record; foreach my $field ( $biblio->field( '440' ) ) { my @newsubfields; diff --git a/misc/migration_tools/upgradeitems.pl b/misc/migration_tools/upgradeitems.pl index 7ba79ae377..40844bf560 100755 --- a/misc/migration_tools/upgradeitems.pl +++ b/misc/migration_tools/upgradeitems.pl @@ -6,7 +6,7 @@ use strict; use Koha::Script; use C4::Context; use C4::Items qw( ModItemFromMarc ); -use C4::Biblio qw( GetMarcBiblio ); +use Koha::Biblios; my $dbh=C4::Context->dbh; @@ -20,7 +20,8 @@ my $rqitemnumber=$dbh->prepare("SELECT itemnumber, biblionumber from items where $rqbiblios->execute; $|=1; while (my ($biblionumber)= $rqbiblios->fetchrow_array){ - my $record=GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; foreach my $itemfield ($record->field('995')){ my $marcitem=MARC::Record->new(); $marcitem->encoding('UTF-8'); diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index fe54ca75b6..cacdbe4a0a 100755 --- a/opac/opac-basket.pl +++ b/opac/opac-basket.pl @@ -22,7 +22,6 @@ use CGI qw ( -utf8 ); use C4::Koha; use C4::Biblio qw( GetFrameworkCode - GetMarcBiblio GetMarcSeries GetMarcSubjects GetMarcUrls @@ -82,7 +81,7 @@ foreach my $biblionumber ( @bibs ) { # No filtering on the item records needed for the record itself # since the only reason item information is grabbed is because of branchcodes. - my $record = &GetMarcBiblio({ biblionumber => $biblionumber }); + my $record = $biblio->metadata->record; my $framework = &GetFrameworkCode( $biblionumber ); $record_processor->options({ interface => 'opac', diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index e62a3ba9af..cd71a6af29 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -25,7 +25,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc ); use C4::Circulation qw( GetBranchItemRule GetTransfers ); use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest ); -use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio ); +use C4::Biblio qw( GetBiblioData GetFrameworkCode ); use C4::Items qw( GetHostItemsInfo GetItemsInfo ); use C4::Output qw( output_html_with_http_headers ); use C4::Context; @@ -150,7 +150,10 @@ foreach my $biblioNumber (@biblionumbers) { my @itemInfos = GetItemsInfo($biblioNumber); - my $marcrecord= GetMarcBiblio({ biblionumber => $biblioNumber }); + my $biblio = Koha::Biblios->find( $biblioNumber ); + next unless $biblio; + + my $marcrecord = $biblio->metadata->record; # flag indicating existence of at least one item linked via a host record # adding items linked via host biblios @@ -165,9 +168,6 @@ foreach my $biblioNumber (@biblionumbers) { } # Compute the priority rank. - my $biblio = Koha::Biblios->find( $biblioNumber ); - next unless $biblio; - $biblioData->{object} = $biblio; my $holds = $biblio->holds; my $rank = $holds->count; diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 42a889869d..3bdbffc762 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -21,7 +21,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); -use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio ); +use C4::Biblio qw( GetBiblioData GetFrameworkCode ); use C4::External::BakerTaylor qw( image_url link_url ); use C4::Koha qw( GetNormalizedEAN @@ -317,10 +317,11 @@ if ( $op eq 'view' ) { while ( my $content = $contents->next ) { my $biblionumber = $content->biblionumber; my $this_item = GetBiblioData($biblionumber); - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); - my $framework = GetFrameworkCode( $biblionumber ); - my $biblio = Koha::Biblios->find( $biblionumber ); - $record_processor->options({ + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; + my $framework = GetFrameworkCode($biblionumber); + $record_processor->options( + { interface => 'opac', frameworkcode => $framework }); diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl index e6aab17d60..7a72214bbf 100755 --- a/opac/opac-showreviews.pl +++ b/opac/opac-showreviews.pl @@ -29,8 +29,8 @@ use C4::Koha qw( GetNormalizedUPC ); use C4::Output qw( output_html_with_http_headers ); -use C4::Biblio qw( GetMarcBiblio ); use Koha::DateUtils qw( dt_from_string ); +use Koha::Biblios; use Koha::Patrons; use Koha::Reviews; use POSIX qw( ceil floor ); @@ -93,7 +93,7 @@ for my $result (@$reviews){ my $biblionumber = $result->{biblionumber}; my $biblio = Koha::Biblios->find( $biblionumber ); my $biblioitem = $biblio->biblioitem; - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $record = $biblio->metadata->record; $result->{normalized_upc} = GetNormalizedUPC($record,$marcflavour); $result->{normalized_ean} = GetNormalizedEAN($record,$marcflavour); $result->{normalized_oclc} = GetNormalizedOCLCNumber($record,$marcflavour); diff --git a/opac/tracklinks.pl b/opac/tracklinks.pl index 5385beac6d..ee74d8bd82 100755 --- a/opac/tracklinks.pl +++ b/opac/tracklinks.pl @@ -23,6 +23,7 @@ use C4::Context; use C4::Auth qw( checkauth ); use C4::Biblio; use C4::Output qw( output_error ); +use Koha::Biblios; use Koha::Items; use Koha::Linktracker; use CGI qw ( -utf8 ); @@ -59,7 +60,8 @@ if ($uri && ($biblionumber || $itemnumber) ) { # get borrower info } - my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; my $marc_urls = $record ? C4::Biblio::GetMarcUrls($record, C4::Context->preference('marcflavour')) : []; my $search_crit = { uri => { -like => "%$uri%" } }; if( $itemnumber ) { # itemnumber is leading over biblionumber diff --git a/t/db_dependent/Authority/Merge.t b/t/db_dependent/Authority/Merge.t index efa9a30fc7..3041662f50 100755 --- a/t/db_dependent/Authority/Merge.t +++ b/t/db_dependent/Authority/Merge.t @@ -13,10 +13,11 @@ use Test::MockModule; use t::lib::Mocks; use t::lib::TestBuilder; -use C4::Biblio qw( AddBiblio GetMarcBiblio ModBiblio ); +use C4::Biblio qw( AddBiblio ModBiblio ); use Koha::Authorities; use Koha::Authority::ControlledIndicators; use Koha::Authority::MergeRequests; +use Koha::Biblios; use Koha::Database; BEGIN { @@ -95,13 +96,13 @@ subtest 'Test merge A1 to A2 (within same authtype)' => sub { is( $rv, 1, 'We expect one biblio record (out of two) to be updated' ); # Check the results - my $newbiblio1 = GetMarcBiblio({ biblionumber => $biblionumber1 }); + my $newbiblio1 = Koha::Biblios->find($biblionumber1)->metadata->record; compare_fields( $biblio1, $newbiblio1, {}, 'count' ); compare_fields( $biblio1, $newbiblio1, {}, 'order' ); is( $newbiblio1->subfield('609', '9'), $authid1, 'Check biblio1 609$9' ); is( $newbiblio1->subfield('609', 'a'), 'George Orwell', 'Check biblio1 609$a' ); - my $newbiblio2 = GetMarcBiblio({ biblionumber => $biblionumber2 }); + my $newbiblio2 = Koha::Biblios->find($biblionumber2)->metadata->record; compare_fields( $biblio2, $newbiblio2, {}, 'count' ); compare_fields( $biblio2, $newbiblio2, {}, 'order' ); is( $newbiblio2->subfield('609', '9'), $authid1, 'Check biblio2 609$9' ); @@ -139,11 +140,11 @@ subtest 'Test merge A1 to modified A1, test strict mode' => sub { is( $rv, 2, 'Both records are updated now' ); #Check the results - my $biblio1 = GetMarcBiblio({ biblionumber => $biblionumber1 }); + my $biblio1 = Koha::Biblios->find($biblionumber1)->metadata->record; compare_fields( $MARC1, $biblio1, {}, 'count' ); compare_fields( $MARC1, $biblio1, {}, 'order' ); is( $auth1new->field(109)->subfield('a'), $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' ); - my $biblio2 = GetMarcBiblio({ biblionumber => $biblionumber2 }); + my $biblio2 = Koha::Biblios->find($biblionumber2)->metadata->record; compare_fields( $MARC2, $biblio2, {}, 'count' ); compare_fields( $MARC2, $biblio2, {}, 'order' ); is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' ); @@ -155,7 +156,7 @@ subtest 'Test merge A1 to modified A1, test strict mode' => sub { ModBiblio( $MARC1, $biblionumber1, '' ); @linkedrecords = ( $biblionumber1 ); $rv = C4::AuthoritiesMarc::merge({ mergefrom => $authid1, MARCfrom => $auth1old, mergeto => $authid1, MARCto => $auth1new }); - $biblio1 = GetMarcBiblio({ biblionumber => $biblionumber1 }); + $biblio1 = Koha::Biblios->find($biblionumber1)->metadata->record; is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' ); compare_fields( $MARC1, $biblio1, { 609 => 1 }, 'count' ); my @old609 = $MARC1->field('609'); @@ -196,7 +197,7 @@ subtest 'Test merge A1 to B1 (changing authtype)' => sub { MARC::Field->new( '612', '', '', a => 'unrelated', 9 => 'other' ), ); my ( $biblionumber ) = C4::Biblio::AddBiblio( $marc, '' ); - my $oldbiblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $oldbiblio = Koha::Biblios->find($biblionumber)->metadata->record; # Time to merge @linkedrecords = ( $biblionumber ); @@ -204,7 +205,7 @@ subtest 'Test merge A1 to B1 (changing authtype)' => sub { is( $retval, 1, 'We touched only one biblio' ); # Get new marc record for compares - my $newbiblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $newbiblio = Koha::Biblios->find($biblionumber)->metadata->record; compare_fields( $oldbiblio, $newbiblio, {}, 'count' ); # Exclude 109/609 and 112/612 in comparing order my $excl = { '109' => 1, '112' => 1, '609' => 1, '612' => 1 }; @@ -261,7 +262,7 @@ subtest 'Merging authorities should handle deletes (BZ 18070)' => sub { DelAuthority({ authid => $authid1 }); # this triggers a merge call # See what happened in the biblio record - my $marc1 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $marc1 = Koha::Biblios->find($biblionumber)->metadata->record; is( $marc1->field('609'), undef, 'Field 609 should be gone too' ); # Now we simulate the delete as done in the cron job @@ -283,7 +284,7 @@ subtest 'Merging authorities should handle deletes (BZ 18070)' => sub { $mocks->{auth_mod}->unmock_all; merge({ mergefrom => $authid1, biblionumbers => [ $biblionumber ] }); # Final check - $marc1 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + $marc1 = Koha::Biblios->find($biblionumber)->metadata->record; is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' ); }; @@ -307,14 +308,14 @@ subtest "Test some specific postponed merge issues" => sub { # This proves the !authtypefrom condition in sub merge # Additionally, we test clearing subfield merge({ mergefrom => $id + 1, MARCfrom => $oldauthmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] }); - $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + $biblio = Koha::Biblios->find($biblionumber)->metadata->record; is( $biblio->subfield('609', '9'), $id, '612 moved to 609' ); is( $biblio->subfield('609', 'c'), undef, '609c cleared correctly' ); # Merge A to B postponed, delete B immediately (hits B < hits A) # This proves the !@record_to test in sub merge merge({ mergefrom => $id + 2, mergeto => $id + 1, MARCto => undef, biblionumbers => [ $biblionumber ] }); - $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + $biblio = Koha::Biblios->find($biblionumber)->metadata->record; is( $biblio->field('612'), undef, 'Last 612 must be gone' ); # Show that we 'need' skip_merge; this example is far-fetched. @@ -326,7 +327,7 @@ subtest "Test some specific postponed merge issues" => sub { my $restored_mocks = set_mocks(); DelAuthority({ authid => $id, skip_merge => 1 }); # delete A $restored_mocks->{auth_mod}->unmock_all; - $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + $biblio = Koha::Biblios->find($biblionumber)->metadata->record; is( $biblio->subfield('109', '9'), $id, 'If the 109 is no longer present, another modify merge would not bring it back' ); # Bug 22437 now removes older postponed A->A merges in DelAuthority @@ -367,7 +368,7 @@ subtest "Graceful resolution of missing reporting tag" => sub { # Merge merge({ mergefrom => $id1, MARCfrom => $authmarc, mergeto => $id2, MARCto => $authmarc, biblionumbers => [ $biblionumber ] }); - $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + $biblio = Koha::Biblios->find($biblionumber)->metadata->record; is( $biblio->subfield('612', '9'), $id2, 'id2 saved in $9' ); is( $biblio->subfield('612', 'a'), ' ', 'Kept an empty $a too' ); @@ -392,7 +393,7 @@ subtest 'merge should not reorder too much' => sub { # Merge 109 and 609 and check order of subfields merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] }); - my $biblio2 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio2 = Koha::Biblios->find($biblionumber)->metadata->record; my $subfields = [ map { $_->[0] } $biblio2->field('109')->subfields ]; is_deeply( $subfields, [ 'i', 'a', 'b', 'c', '9' ], 'Merge only moved $9' ); $subfields = [ map { $_->[0] } $biblio2->field('609')->subfields ]; @@ -422,7 +423,7 @@ subtest 'Test how merge handles controlled indicators' => sub { # Merge and check indicators and $2 merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] }); - my $biblio2 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio2 = Koha::Biblios->find($biblionumber)->metadata->record; is( $biblio2->field('609')->indicator(1), '7', 'Indicator1 OK' ); is( $biblio2->field('609')->indicator(2), '7', 'Indicator2 OK' ); is( $biblio2->subfield('609', '2'), 'aat', 'Subfield $2 OK' ); @@ -431,7 +432,7 @@ subtest 'Test how merge handles controlled indicators' => sub { $authmarc->field('008')->update( (' 'x11).'a' ); # LOC, no $2 needed AddAuthority( $authmarc, $id, $authtype1 ); # modify merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] }); - $biblio2 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + $biblio2 = Koha::Biblios->find($biblionumber)->metadata->record; is( $biblio2->subfield('609', '2'), undef, 'No subfield $2 left' ); }; diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl index 923c902f04..a1781802b8 100755 --- a/tools/batch_delete_records.pl +++ b/tools/batch_delete_records.pl @@ -27,7 +27,7 @@ use Try::Tiny; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); -use C4::Biblio qw( GetMarcBiblio ); +use C4::Biblio; use C4::AuthoritiesMarc; use Koha::Virtualshelves; @@ -101,7 +101,7 @@ if ( $op eq 'form' ) { next; } my $biblio = $biblio_object->unblessed; - my $record = &GetMarcBiblio({ biblionumber => $record_id }); + my $record = $biblio_object->metadata->record; $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')]; $biblio->{holds_count} = $biblio_object->holds->count; $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id ); diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index a722326ad0..8b70dc2bb5 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -20,7 +20,6 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); -use C4::Biblio qw( GetMarcBiblio ); use C4::Koha qw( GetNormalizedEAN GetNormalizedISBN @@ -265,7 +264,8 @@ if ( $op eq 'view' ) { while ( my $content = $contents->next ) { my $this_item; my $biblionumber = $content->biblionumber; - my $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $biblio = Koha::Biblios->find($biblionumber); + my $record = $biblio->metadata->record; $this_item->{XSLTBloc} = XSLTParse4Display( { @@ -279,7 +279,6 @@ if ( $op eq 'view' ) { my $marcflavour = C4::Context->preference("marcflavour"); my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype; $itemtype = Koha::ItemTypes->find( $itemtype ); - my $biblio = Koha::Biblios->find( $content->biblionumber ); $this_item->{title} = $biblio->title; $this_item->{subtitle} = $biblio->subtitle; $this_item->{medium} = $biblio->medium; -- 2.30.2