Bug 29697: Replace GetMarcBiblio occurrences with $biblio->metadata->record

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

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ä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-01-21 11:03:15 +01:00 committed by Tomas Cohen Arazi
parent 790bab24b1
commit 70d61d80fb
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
44 changed files with 204 additions and 142 deletions

View File

@ -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

View File

@ -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}) {

View File

@ -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 );

View File

@ -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;
}

View File

@ -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 ); };

View File

@ -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);

View File

@ -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, {

View File

@ -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;

View File

@ -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;
@ -491,8 +492,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} ) {

View File

@ -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

View File

@ -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 );

View File

@ -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);

View File

@ -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;

View File

@ -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");

View File

@ -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 ) ;

View File

@ -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 } );

View File

@ -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 );
}

View File

@ -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 = {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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($@){

View File

@ -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');

View File

@ -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++;
}

View File

@ -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;
}

View File

@ -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] ) });

View File

@ -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)) ;
}

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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);
#

View File

@ -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');

View File

@ -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";

View File

@ -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";

View File

@ -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;

View File

@ -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');

View File

@ -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',

View File

@ -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;

View File

@ -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
@ -353,10 +353,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
});

View File

@ -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);

View File

@ -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

View File

@ -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' );
};

View File

@ -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 );

View File

@ -20,7 +20,6 @@
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( get_template_and_user haspermission );
use C4::Biblio qw( GetMarcBiblio );
use C4::Circulation qw( barcodedecode );
use C4::Context;
use C4::Koha qw(
@ -286,7 +285,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(
{
@ -300,7 +300,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;