View | Details | Raw Unified | Return to bug 29697
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-3 / +4 lines)
Lines 23-29 use warnings; Link Here
23
use MARC::Field;
23
use MARC::Field;
24
24
25
use C4::Context;
25
use C4::Context;
26
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblio );
26
use C4::Biblio qw( GetFrameworkCode ModBiblio );
27
use C4::Search qw( FindDuplicate new_record_from_zebra );
27
use C4::Search qw( FindDuplicate new_record_from_zebra );
28
use C4::AuthoritiesMarc::MARC21;
28
use C4::AuthoritiesMarc::MARC21;
29
use C4::AuthoritiesMarc::UNIMARC;
29
use C4::AuthoritiesMarc::UNIMARC;
Lines 1463-1470 sub merge { Link Here
1463
1463
1464
    my $counteditedbiblio = 0;
1464
    my $counteditedbiblio = 0;
1465
    foreach my $biblionumber ( @biblionumbers ) {
1465
    foreach my $biblionumber ( @biblionumbers ) {
1466
        my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
1466
        my $biblio = Koha::Biblios->find($biblionumber);
1467
        next if !$marcrecord;
1467
        next unless $biblio;
1468
        my $marcrecord = $biblio->metadata->record;
1468
        my $update = 0;
1469
        my $update = 0;
1469
        foreach my $tagfield (@$tags_using_authtype) {
1470
        foreach my $tagfield (@$tags_using_authtype) {
1470
            my $countfrom = 0;    # used in strict mode to remove duplicates
1471
            my $countfrom = 0;    # used in strict mode to remove duplicates
(-)a/C4/Biblio.pm (-12 / +17 lines)
Lines 364-371 sub ModBiblio { Link Here
364
    }
364
    }
365
365
366
    if ( C4::Context->preference("CataloguingLog") ) {
366
    if ( C4::Context->preference("CataloguingLog") ) {
367
        my $newrecord = GetMarcBiblio({ biblionumber => $biblionumber });
367
        my $biblio = Koha::Biblios->find($biblionumber);
368
        logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $newrecord->as_formatted );
368
        logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $biblio->metadata->record->as_formatted );
369
    }
369
    }
370
370
371
    if ( !$options->{disable_autolink} && C4::Context->preference('BiblioAddsAuthorities') ) {
371
    if ( !$options->{disable_autolink} && C4::Context->preference('BiblioAddsAuthorities') ) {
Lines 1948-1955 This function returns a host field populated with data from the host record, the Link Here
1948
sub PrepHostMarcField {
1948
sub PrepHostMarcField {
1949
    my ($hostbiblionumber,$hostitemnumber, $marcflavour) = @_;
1949
    my ($hostbiblionumber,$hostitemnumber, $marcflavour) = @_;
1950
    $marcflavour ||="MARC21";
1950
    $marcflavour ||="MARC21";
1951
    
1951
1952
    my $hostrecord = GetMarcBiblio({ biblionumber => $hostbiblionumber });
1952
    my $biblio = Koha::Biblios->find($hostbiblionumber);
1953
    my $hostrecord = $biblio->metadata->record;
1953
    my $item = Koha::Items->find($hostitemnumber);
1954
    my $item = Koha::Items->find($hostitemnumber);
1954
1955
1955
	my $hostmarcfield;
1956
	my $hostmarcfield;
Lines 2952-2958 Generate the host item entry for an analytic child entry Link Here
2952
sub prepare_host_field {
2953
sub prepare_host_field {
2953
    my ( $hostbiblio, $marcflavour ) = @_;
2954
    my ( $hostbiblio, $marcflavour ) = @_;
2954
    $marcflavour ||= C4::Context->preference('marcflavour');
2955
    $marcflavour ||= C4::Context->preference('marcflavour');
2955
    my $host = GetMarcBiblio({ biblionumber => $hostbiblio });
2956
2957
    my $biblio = Koha::Biblios->find($hostbiblio);
2958
    my $host = $biblio->metadata->record;
2956
    # unfortunately as_string does not 'do the right thing'
2959
    # unfortunately as_string does not 'do the right thing'
2957
    # if field returns undef
2960
    # if field returns undef
2958
    my %sfd;
2961
    my %sfd;
Lines 3090-3105 sub UpdateTotalIssues { Link Here
3090
    my ($biblionumber, $increase, $value, $skip_holds_queue) = @_;
3093
    my ($biblionumber, $increase, $value, $skip_holds_queue) = @_;
3091
    my $totalissues;
3094
    my $totalissues;
3092
3095
3093
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
3096
    my $biblio = Koha::Biblios->find($biblionumber);
3094
    unless ($record) {
3095
        carp "UpdateTotalIssues could not get biblio record";
3096
        return;
3097
    }
3098
    my $biblio = Koha::Biblios->find( $biblionumber );
3099
    unless ($biblio) {
3097
    unless ($biblio) {
3100
        carp "UpdateTotalIssues could not get datas of biblio";
3098
        carp "UpdateTotalIssues could not get datas of biblio";
3101
        return;
3099
        return;
3102
    }
3100
    }
3101
3102
    my $record = $biblio->metadata->record;
3103
    unless ($record) {
3104
        carp "UpdateTotalIssues could not get biblio record";
3105
        return;
3106
    }
3103
    my $biblioitem = $biblio->biblioitem;
3107
    my $biblioitem = $biblio->biblioitem;
3104
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3108
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3105
    unless ($totalissuestag) {
3109
    unless ($totalissuestag) {
Lines 3223-3229 sub ApplyMarcOverlayRules { Link Here
3223
        carp 'ApplyMarcOverlayRules called on undefined record';
3227
        carp 'ApplyMarcOverlayRules called on undefined record';
3224
        return;
3228
        return;
3225
    }
3229
    }
3226
    my $old_record = GetMarcBiblio({ biblionumber => $biblionumber });
3230
    my $biblio = Koha::Biblios->find($biblionumber);
3231
    my $old_record = $biblio->metadata->record;
3227
3232
3228
    # Skip overlay rules if called with no context
3233
    # Skip overlay rules if called with no context
3229
    if ($old_record && defined $params->{overlay_context}) {
3234
    if ($old_record && defined $params->{overlay_context}) {
(-)a/C4/Items.pm (-1 / +3 lines)
Lines 64-69 use Koha::AuthorisedValues; Link Here
64
use Koha::DateUtils qw( dt_from_string output_pref );
64
use Koha::DateUtils qw( dt_from_string output_pref );
65
use Koha::Database;
65
use Koha::Database;
66
66
67
use Koha::Biblios;
67
use Koha::Biblioitems;
68
use Koha::Biblioitems;
68
use Koha::Items;
69
use Koha::Items;
69
use Koha::ItemTypes;
70
use Koha::ItemTypes;
Lines 948-954 sub get_hostitemnumbers_of { Link Here
948
        return ();
949
        return ();
949
    }
950
    }
950
951
951
    my $marcrecord = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
952
    my $biblio = Koha::Biblios->find($biblionumber);
953
    my $marcrecord = $biblio->metadata->record;
952
    return unless $marcrecord;
954
    return unless $marcrecord;
953
955
954
    my ( @returnhostitemnumbers, $tag, $biblio_s, $item_s );
956
    my ( @returnhostitemnumbers, $tag, $biblio_s, $item_s );
(-)a/C4/Labels/Label.pm (-3 / +6 lines)
Lines 9-15 use Text::CSV_XS; Link Here
9
use Text::Bidi qw( log2vis );
9
use Text::Bidi qw( log2vis );
10
10
11
use C4::Context;
11
use C4::Context;
12
use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField );
12
use C4::Biblio qw( GetMarcFromKohaField );
13
use Koha::Biblios;
13
use Koha::ClassSources;
14
use Koha::ClassSources;
14
use Koha::ClassSortRules;
15
use Koha::ClassSortRules;
15
use Koha::ClassSplitRules;
16
use Koha::ClassSplitRules;
Lines 337-343 sub draw_label_text { Link Here
337
    my $font = $self->{'font'};
338
    my $font = $self->{'font'};
338
    my $item = _get_label_item($self->{'item_number'});
339
    my $item = _get_label_item($self->{'item_number'});
339
    my $label_fields = _get_text_fields($self->{'format_string'});
340
    my $label_fields = _get_text_fields($self->{'format_string'});
340
    my $record = GetMarcBiblio({ biblionumber => $item->{'biblionumber'} });
341
    my $biblio = Koha::Biblios->find($item->{biblionumber});
342
    my $record = $biblio->metadata->record;
341
    # FIXME - returns all items, so you can't get data from an embedded holdings field.
343
    # FIXME - returns all items, so you can't get data from an embedded holdings field.
342
    # TODO - add a GetMarcBiblio1item(bibnum,itemnum) or a GetMarcItem(itemnum).
344
    # TODO - add a GetMarcBiblio1item(bibnum,itemnum) or a GetMarcItem(itemnum).
343
    my $cn_source = ($item->{'cn_source'} ? $item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource'));
345
    my $cn_source = ($item->{'cn_source'} ? $item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource'));
Lines 554-560 sub csv_data { Link Here
554
    my $self = shift;
556
    my $self = shift;
555
    my $label_fields = _get_text_fields($self->{'format_string'});
557
    my $label_fields = _get_text_fields($self->{'format_string'});
556
    my $item = _get_label_item($self->{'item_number'});
558
    my $item = _get_label_item($self->{'item_number'});
557
    my $bib_record = GetMarcBiblio({ biblionumber => $item->{biblionumber} });
559
    my $biblio = Koha::Biblios->find($item->{biblionumber});
560
    my $bib_record = $biblio->metadata->record;
558
    my @csv_data = (map { _get_barcode_data($_->{'code'},$item,$bib_record) } @$label_fields);
561
    my @csv_data = (map { _get_barcode_data($_->{'code'},$item,$bib_record) } @$label_fields);
559
    return \@csv_data;
562
    return \@csv_data;
560
}
563
}
(-)a/C4/Serials.pm (-2 / +3 lines)
Lines 32-42 use Date::Calc qw( Link Here
32
    Today
32
    Today
33
);
33
);
34
use POSIX qw( strftime );
34
use POSIX qw( strftime );
35
use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ModBiblio );
35
use C4::Biblio qw( GetMarcFromKohaField ModBiblio );
36
use C4::Log qw( logaction );    # logaction
36
use C4::Log qw( logaction );    # logaction
37
use C4::Serials::Frequency qw( GetSubscriptionFrequency );
37
use C4::Serials::Frequency qw( GetSubscriptionFrequency );
38
use C4::Serials::Numberpattern;
38
use C4::Serials::Numberpattern;
39
use Koha::AdditionalFieldValues;
39
use Koha::AdditionalFieldValues;
40
use Koha::Biblios;
40
use Koha::DateUtils qw( dt_from_string output_pref );
41
use Koha::DateUtils qw( dt_from_string output_pref );
41
use Koha::Serial;
42
use Koha::Serial;
42
use Koha::Subscriptions;
43
use Koha::Subscriptions;
Lines 1497-1503 sub NewSubscription { Link Here
1497
    #set serial flag on biblio if not already set.
1498
    #set serial flag on biblio if not already set.
1498
    my $biblio = Koha::Biblios->find( $biblionumber );
1499
    my $biblio = Koha::Biblios->find( $biblionumber );
1499
    if ( $biblio and !$biblio->serial ) {
1500
    if ( $biblio and !$biblio->serial ) {
1500
        my $record = GetMarcBiblio({ biblionumber => $biblionumber });
1501
        my $record = $biblio->metadata->record;
1501
        my ( $tag, $subf ) = GetMarcFromKohaField( 'biblio.serial' );
1502
        my ( $tag, $subf ) = GetMarcFromKohaField( 'biblio.serial' );
1502
        if ($tag) {
1503
        if ($tag) {
1503
            eval { $record->field($tag)->update( $subf => 1 ); };
1504
            eval { $record->field($tag)->update( $subf => 1 ); };
(-)a/C4/ShelfBrowser.pm (-2 / +2 lines)
Lines 20-26 package C4::ShelfBrowser; Link Here
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
22
23
use C4::Biblio qw( GetAuthorisedValueDesc GetMarcBiblio );
23
use C4::Biblio qw( GetAuthorisedValueDesc );
24
use C4::Context;
24
use C4::Context;
25
use C4::Koha qw( GetNormalizedUPC GetNormalizedOCLCNumber GetNormalizedISBN GetNormalizedEAN );
25
use C4::Koha qw( GetNormalizedUPC GetNormalizedOCLCNumber GetNormalizedISBN GetNormalizedEAN );
26
use Koha::Biblios;
26
use Koha::Biblios;
Lines 226-232 sub GetShelfInfo { Link Here
226
        $item->{medium}        = $biblio->medium;
226
        $item->{medium}        = $biblio->medium;
227
        $item->{part_number}   = $biblio->part_number;
227
        $item->{part_number}   = $biblio->part_number;
228
        $item->{part_name}     = $biblio->part_name;
228
        $item->{part_name}     = $biblio->part_name;
229
        my $this_record = GetMarcBiblio({ biblionumber => $biblio->biblionumber });
229
        my $this_record = $biblio->metadata->record;
230
        $item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
230
        $item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
231
        $item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
231
        $item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
232
        $item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
232
        $item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
(-)a/Koha/BackgroundJob/BatchUpdateBiblio.pm (-1 / +3 lines)
Lines 18-23 package Koha::BackgroundJob::BatchUpdateBiblio; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use JSON qw( decode_json encode_json );
19
use JSON qw( decode_json encode_json );
20
20
21
use Koha::Biblios;
21
use Koha::DateUtils qw( dt_from_string );
22
use Koha::DateUtils qw( dt_from_string );
22
use Koha::Virtualshelves;
23
use Koha::Virtualshelves;
23
use Koha::SearchEngine;
24
use Koha::SearchEngine;
Lines 87-93 sub process { Link Here
87
88
88
        # Modify the biblio
89
        # Modify the biblio
89
        my $error = eval {
90
        my $error = eval {
90
            my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
91
            my $biblio = Koha::Biblios->find($biblionumber);
92
            my $record = $biblio->metadata->record;
91
            C4::MarcModificationTemplates::ModifyRecordWithTemplate( $mmtid, $record );
93
            C4::MarcModificationTemplates::ModifyRecordWithTemplate( $mmtid, $record );
92
            my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber );
94
            my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber );
93
            C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, {
95
            C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, {
(-)a/Koha/Exporter/Record.pm (-1 / +3 lines)
Lines 7-12 use MARC::File::USMARC; Link Here
7
use C4::AuthoritiesMarc;
7
use C4::AuthoritiesMarc;
8
use C4::Biblio qw( GetMarcFromKohaField );
8
use C4::Biblio qw( GetMarcFromKohaField );
9
use C4::Record;
9
use C4::Record;
10
use Koha::Biblios;
10
use Koha::CsvProfiles;
11
use Koha::CsvProfiles;
11
use Koha::Logger;
12
use Koha::Logger;
12
use List::Util qw( all any );
13
use List::Util qw( all any );
Lines 120-126 sub _get_biblio_for_export { Link Here
120
    my $export_items = $params->{export_items} // 1;
121
    my $export_items = $params->{export_items} // 1;
121
    my $only_export_items_for_branches = $params->{only_export_items_for_branches};
122
    my $only_export_items_for_branches = $params->{only_export_items_for_branches};
122
123
123
    my $record = eval { C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); };
124
    my $biblio = Koha::Biblios->find($biblionumber);
125
    my $record = eval { $biblio->metadata->record };
124
126
125
    return if $@ or not defined $record;
127
    return if $@ or not defined $record;
126
128
(-)a/Koha/UI/Form/Builder/Item.pm (-3 / +5 lines)
Lines 18-27 package Koha::UI::Form::Builder::Item; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use MARC::Record;
19
use MARC::Record;
20
use C4::Context;
20
use C4::Context;
21
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio GetMarcStructure IsMarcStructureInternal );
21
use C4::Biblio qw( GetFrameworkCode GetMarcStructure IsMarcStructureInternal );
22
use C4::Koha qw( GetAuthorisedValues );
22
use C4::Koha qw( GetAuthorisedValues );
23
use C4::ClassSource qw( GetClassSources );
23
use C4::ClassSource qw( GetClassSources );
24
24
25
use Koha::Biblios;
25
use Koha::DateUtils qw( dt_from_string );
26
use Koha::DateUtils qw( dt_from_string );
26
use Koha::Libraries;
27
use Koha::Libraries;
27
28
Lines 484-491 sub edit_form { Link Here
484
      : undef;
485
      : undef;
485
486
486
    my $biblionumber   = $self->{biblionumber};
487
    my $biblionumber   = $self->{biblionumber};
487
    my $frameworkcode  = $biblionumber ? GetFrameworkCode($biblionumber) : q{};
488
    my $biblio         = Koha::Biblios->find($biblionumber);
488
    my $marc_record    = $biblionumber ? GetMarcBiblio( { biblionumber => $biblionumber } ) : undef;
489
    my $frameworkcode  = $biblio ? GetFrameworkCode($biblionumber) : q{};
490
    my $marc_record    = $biblio ? $biblio->metadata->record : undef;
489
    my @subfields;
491
    my @subfields;
490
    my $tagslib = GetMarcStructure( 1, $frameworkcode );
492
    my $tagslib = GetMarcStructure( 1, $frameworkcode );
491
    foreach my $tag ( keys %{$tagslib} ) {
493
    foreach my $tag ( keys %{$tagslib} ) {
(-)a/acqui/neworderempty.pl (-2 / +3 lines)
Lines 77-83 use C4::Suggestions qw( GetSuggestion GetSuggestionInfo ); Link Here
77
use C4::Biblio qw(
77
use C4::Biblio qw(
78
    AddBiblio
78
    AddBiblio
79
    GetBiblioData
79
    GetBiblioData
80
    GetMarcBiblio
81
    GetMarcFromKohaField
80
    GetMarcFromKohaField
82
    GetMarcPrice
81
    GetMarcPrice
83
    GetMarcStructure
82
    GetMarcStructure
Lines 92-97 use C4::ImportBatch qw( SetImportRecordStatus SetMatchedBiblionumber GetImportRe Link Here
92
91
93
use Koha::Acquisition::Booksellers;
92
use Koha::Acquisition::Booksellers;
94
use Koha::Acquisition::Currencies qw( get_active );
93
use Koha::Acquisition::Currencies qw( get_active );
94
use Koha::Biblios;
95
use Koha::BiblioFrameworks;
95
use Koha::BiblioFrameworks;
96
use Koha::DateUtils qw( dt_from_string );
96
use Koha::DateUtils qw( dt_from_string );
97
use Koha::MarcSubfieldStructures;
97
use Koha::MarcSubfieldStructures;
Lines 296-302 $biblionumber = $data->{biblionumber}; Link Here
296
# - no ordernumber, no biblionumber: from a suggestion, from a new order
296
# - no ordernumber, no biblionumber: from a suggestion, from a new order
297
if ( not $ordernumber or $biblionumber ) {
297
if ( not $ordernumber or $biblionumber ) {
298
    if ( C4::Context->preference('UseACQFrameworkForBiblioRecords') ) {
298
    if ( C4::Context->preference('UseACQFrameworkForBiblioRecords') ) {
299
        my $record = $biblionumber ? GetMarcBiblio({ biblionumber => $biblionumber }) : undef;
299
        my $biblio = Koha::Biblios->find($biblionumber);
300
        my $record = $biblio ? $biblio->metadata->record : undef;
300
        foreach my $tag ( sort keys %{$tagslib} ) {
301
        foreach my $tag ( sort keys %{$tagslib} ) {
301
            next if $tag eq '';
302
            next if $tag eq '';
302
            next if $tag eq $itemnumber_tag; # skip items fields
303
            next if $tag eq $itemnumber_tag; # skip items fields
(-)a/basket/basket.pl (-2 / +1 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
use C4::Koha;
21
use C4::Koha;
22
use C4::Biblio qw(
22
use C4::Biblio qw(
23
    GetMarcBiblio
24
    GetMarcSeries
23
    GetMarcSeries
25
    GetMarcSubjects
24
    GetMarcSubjects
26
    GetMarcUrls
25
    GetMarcUrls
Lines 67-73 foreach my $biblionumber ( @bibs ) { Link Here
67
66
68
    my $biblio           = Koha::Biblios->find( $biblionumber ) or next;
67
    my $biblio           = Koha::Biblios->find( $biblionumber ) or next;
69
    my $dat              = $biblio->unblessed;
68
    my $dat              = $biblio->unblessed;
70
    my $record           = &GetMarcBiblio({ biblionumber => $biblionumber });
69
    my $record           = $biblio->metadata->record;
71
    my $marcnotesarray   = $biblio->get_marc_notes;
70
    my $marcnotesarray   = $biblio->get_marc_notes;
72
    my $marcauthorsarray = $biblio->get_marc_authors;
71
    my $marcauthorsarray = $biblio->get_marc_authors;
73
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
72
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
(-)a/catalogue/labeledMARCdetail.pl (-3 / +2 lines)
Lines 26-32 use C4::Output qw( output_html_with_http_headers ); Link Here
26
use C4::Biblio qw(
26
use C4::Biblio qw(
27
    GetBiblioData
27
    GetBiblioData
28
    GetFrameworkCode
28
    GetFrameworkCode
29
    GetMarcBiblio
30
    GetMarcStructure
29
    GetMarcStructure
31
);
30
);
32
use C4::Search qw( z3950_search_args enabled_staff_search_views );
31
use C4::Search qw( z3950_search_args enabled_staff_search_views );
Lines 56-62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
56
    }
55
    }
57
);
56
);
58
57
59
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
58
my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio
59
my $record = $biblio_object->metadata->record;
60
if ( not defined $record ) {
60
if ( not defined $record ) {
61
    # biblionumber invalid -> report and exit
61
    # biblionumber invalid -> report and exit
62
    $template->param( unknownbiblionumber => 1,
62
    $template->param( unknownbiblionumber => 1,
Lines 66-72 if ( not defined $record ) { Link Here
66
    exit;
66
    exit;
67
}
67
}
68
68
69
my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio
70
my $tagslib = GetMarcStructure(1,$frameworkcode);
69
my $tagslib = GetMarcStructure(1,$frameworkcode);
71
my $biblio = GetBiblioData($biblionumber);
70
my $biblio = GetBiblioData($biblionumber);
72
71
(-)a/catalogue/moredetail.pl (-5 / +4 lines)
Lines 23-29 use Modern::Perl; Link Here
23
use C4::Koha qw( GetAuthorisedValues );
23
use C4::Koha qw( GetAuthorisedValues );
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use HTML::Entities;
25
use HTML::Entities;
26
use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
26
use C4::Biblio qw( GetBiblioData GetFrameworkCode );
27
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
27
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
28
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice );
28
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice );
29
use C4::Output qw( output_and_exit output_html_with_http_headers );
29
use C4::Output qw( output_and_exit output_html_with_http_headers );
Lines 113-122 for my $itm (@all_items) { Link Here
113
                               ($itemnumber != $itm->{itemnumber}));
113
                               ($itemnumber != $itm->{itemnumber}));
114
}
114
}
115
115
116
my $record=GetMarcBiblio({ biblionumber => $biblionumber });
116
my $biblio = Koha::Biblios->find( $biblionumber );
117
my $record = $biblio ? $biblio->metadata->record : undef;
117
118
118
output_and_exit( $query, $cookie, $template, 'unknown_biblio')
119
output_and_exit( $query, $cookie, $template, 'unknown_biblio')
119
    unless $record;
120
    unless $biblio && $record;
120
121
121
my $hostrecords;
122
my $hostrecords;
122
# adding items linked via host biblios
123
# adding items linked via host biblios
Lines 126-133 if (@hostitems){ Link Here
126
        push (@items,@hostitems);
127
        push (@items,@hostitems);
127
}
128
}
128
129
129
my $biblio = Koha::Biblios->find( $biblionumber );
130
131
my $totalcount=@all_items;
130
my $totalcount=@all_items;
132
my $showncount=@items;
131
my $showncount=@items;
133
my $hiddencount = $totalcount - $showncount;
132
my $hiddencount = $totalcount - $showncount;
(-)a/catalogue/showmarc.pl (-2 / +4 lines)
Lines 30-38 use Encode; Link Here
30
use C4::Context;
30
use C4::Context;
31
use C4::Output qw( output_html_with_http_headers );
31
use C4::Output qw( output_html_with_http_headers );
32
use C4::Auth qw( get_template_and_user );
32
use C4::Auth qw( get_template_and_user );
33
use C4::Biblio qw( GetMarcBiblio GetXmlBiblio );
33
use C4::Biblio qw( GetXmlBiblio );
34
use C4::XSLT;
34
use C4::XSLT;
35
35
36
use Koha::Biblios;
36
use Koha::Import::Records;
37
use Koha::Import::Records;
37
38
38
my $input= CGI->new;
39
my $input= CGI->new;
Lines 65-71 if ($importid) { Link Here
65
    }
66
    }
66
}
67
}
67
else {
68
else {
68
    $record =GetMarcBiblio({ biblionumber => $biblionumber });
69
    my $biblio = Koha::Biblios->find($biblionumber);
70
    $record = $biblio->metadata->record;
69
}
71
}
70
if(!ref $record) {
72
if(!ref $record) {
71
    print $input->redirect("/cgi-bin/koha/errors/404.pl");
73
    print $input->redirect("/cgi-bin/koha/errors/404.pl");
(-)a/cataloguing/addbiblio.pl (-5 / +6 lines)
Lines 28-34 use C4::Biblio qw( Link Here
28
    AddBiblio
28
    AddBiblio
29
    DelBiblio
29
    DelBiblio
30
    GetFrameworkCode
30
    GetFrameworkCode
31
    GetMarcBiblio
32
    GetMarcFromKohaField
31
    GetMarcFromKohaField
33
    GetMarcStructure
32
    GetMarcStructure
34
    GetUsedMarcStructure
33
    GetUsedMarcStructure
Lines 47-52 use C4::Charset qw( SetMarcUnicodeFlag ); Link Here
47
use Koha::BiblioFrameworks;
46
use Koha::BiblioFrameworks;
48
use Koha::DateUtils qw( dt_from_string );
47
use Koha::DateUtils qw( dt_from_string );
49
48
49
use Koha::Biblios;
50
use Koha::ItemTypes;
50
use Koha::ItemTypes;
51
use Koha::Libraries;
51
use Koha::Libraries;
52
52
Lines 749-757 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
749
    }
749
    }
750
);
750
);
751
751
752
my $biblio;
752
if ($biblionumber){
753
if ($biblionumber){
753
    my $does_bib_exist = Koha::Biblios->find($biblionumber);
754
    $biblio = Koha::Biblios->find($biblionumber);
754
    if (!defined $does_bib_exist){
755
    unless ( $biblio ) {
755
        $biblionumber = undef;
756
        $biblionumber = undef;
756
        $template->param( bib_doesnt_exist => 1 );
757
        $template->param( bib_doesnt_exist => 1 );
757
    }
758
    }
Lines 800-807 my ( Link Here
800
	$biblioitemnumber
801
	$biblioitemnumber
801
);
802
);
802
803
803
if (($biblionumber) && !($breedingid)){
804
if ( $biblio && !$breedingid ) {
804
    $record = GetMarcBiblio({ biblionumber => $biblionumber });
805
    $record = $biblio->metadata->record;
805
}
806
}
806
if ($breedingid) {
807
if ($breedingid) {
807
    ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
808
    ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
(-)a/cataloguing/additem.pl (-2 / +2 lines)
Lines 26-32 use C4::Auth qw( get_template_and_user haspermission ); Link Here
26
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
26
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
27
use C4::Biblio qw(
27
use C4::Biblio qw(
28
    GetFrameworkCode
28
    GetFrameworkCode
29
    GetMarcBiblio
30
    GetMarcFromKohaField
29
    GetMarcFromKohaField
31
    GetMarcStructure
30
    GetMarcStructure
32
    IsMarcStructureInternal
31
    IsMarcStructureInternal
Lines 37-42 use C4::Circulation qw( barcodedecode LostItem ); Link Here
37
use C4::Barcodes;
36
use C4::Barcodes;
38
use C4::Barcodes::ValueBuilder;
37
use C4::Barcodes::ValueBuilder;
39
use Koha::DateUtils qw( dt_from_string );
38
use Koha::DateUtils qw( dt_from_string );
39
use Koha::Biblios;
40
use Koha::Items;
40
use Koha::Items;
41
use Koha::ItemTypes;
41
use Koha::ItemTypes;
42
use Koha::Items;
42
use Koha::Items;
Lines 163-169 $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibra Link Here
163
$restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'}));
163
$restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'}));
164
164
165
our $tagslib = &GetMarcStructure(1,$frameworkcode);
165
our $tagslib = &GetMarcStructure(1,$frameworkcode);
166
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
166
my $record = $biblio->metadata->record;
167
167
168
output_and_exit_if_error( $input, $cookie, $template,
168
output_and_exit_if_error( $input, $cookie, $template,
169
    { module => 'cataloguing', record => $record } );
169
    { module => 'cataloguing', record => $record } );
(-)a/cataloguing/linkitem.pl (-6 / +8 lines)
Lines 24-31 use Modern::Perl; Link Here
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use C4::Auth qw( get_template_and_user );
25
use C4::Auth qw( get_template_and_user );
26
use C4::Output qw( output_html_with_http_headers );
26
use C4::Output qw( output_html_with_http_headers );
27
use C4::Biblio qw( GetMarcBiblio ModBiblio PrepHostMarcField );
27
use C4::Biblio qw( ModBiblio PrepHostMarcField );
28
use C4::Context;
28
use C4::Context;
29
use Koha::Biblios;
29
30
30
31
31
my $query = CGI->new;
32
my $query = CGI->new;
Lines 42-54 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
42
    }
43
    }
43
);
44
);
44
45
45
my $biblio = GetMarcBiblio({ biblionumber => $biblionumber });
46
my $biblio = Koha::Biblios->find($biblionumber);
47
my $record = $biblio->metadata->record;
46
my $marcflavour = C4::Context->preference("marcflavour");
48
my $marcflavour = C4::Context->preference("marcflavour");
47
$marcflavour ||="MARC21";
49
$marcflavour ||="MARC21";
48
if ($marcflavour eq 'MARC21') {
50
if ($marcflavour eq 'MARC21') {
49
    $template->param(bibliotitle => $biblio->subfield('245','a'));
51
    $template->param(bibliotitle => $record->subfield('245','a'));
50
} elsif ($marcflavour eq 'UNIMARC') {
52
} elsif ($marcflavour eq 'UNIMARC') {
51
    $template->param(bibliotitle => $biblio->subfield('200','a'));
53
    $template->param(bibliotitle => $record->subfield('200','a'));
52
}
54
}
53
55
54
$template->param(biblionumber => $biblionumber);
56
$template->param(biblionumber => $biblionumber);
Lines 59-67 if ( $barcode && $biblionumber ) { Link Here
59
61
60
    if ($item) {
62
    if ($item) {
61
        my $field = PrepHostMarcField( $item->biblio->biblionumber, $item->itemnumber, $marcflavour );
63
        my $field = PrepHostMarcField( $item->biblio->biblionumber, $item->itemnumber, $marcflavour );
62
        $biblio->append_fields($field);
64
        $record->append_fields($field);
63
65
64
        my $modresult = ModBiblio( $biblio, $biblionumber, '' );
66
        my $modresult = ModBiblio( $record, $biblionumber, '' );
65
        if ($modresult) {
67
        if ($modresult) {
66
            $template->param( success => 1 );
68
            $template->param( success => 1 );
67
        }
69
        }
(-)a/cataloguing/merge.pl (-5 / +7 lines)
Lines 27-33 use C4::Biblio qw( Link Here
27
    DelBiblio
27
    DelBiblio
28
    GetBiblioData
28
    GetBiblioData
29
    GetFrameworkCode
29
    GetFrameworkCode
30
    GetMarcBiblio
31
    GetMarcFromKohaField
30
    GetMarcFromKohaField
32
    GetMarcStructure
31
    GetMarcStructure
33
    ModBiblio
32
    ModBiblio
Lines 85-91 if ($merge) { Link Here
85
    }
84
    }
86
85
87
    # Rewriting the leader
86
    # Rewriting the leader
88
    $record->leader(GetMarcBiblio({ biblionumber => $ref_biblionumber })->leader());
87
    my $biblio = Koha::Biblios->find($ref_biblionumber);
88
    $record->leader($biblio->metadata->record->leader());
89
89
90
    my $frameworkcode = $input->param('frameworkcode');
90
    my $frameworkcode = $input->param('frameworkcode');
91
91
Lines 93-99 if ($merge) { Link Here
93
    ModBiblio($record, $ref_biblionumber, $frameworkcode);
93
    ModBiblio($record, $ref_biblionumber, $frameworkcode);
94
94
95
    # Moving items and article requests from the other record to the reference record
95
    # Moving items and article requests from the other record to the reference record
96
    my $biblio = Koha::Biblios->find($ref_biblionumber);
96
    $biblio = $biblio->get_from_storage;
97
    foreach my $biblionumber (@biblionumbers) {
97
    foreach my $biblionumber (@biblionumbers) {
98
        my $from_biblio = Koha::Biblios->find($biblionumber);
98
        my $from_biblio = Koha::Biblios->find($biblionumber);
99
        $from_biblio->items->move_to_biblio($biblio);
99
        $from_biblio->items->move_to_biblio($biblio);
Lines 116-122 if ($merge) { Link Here
116
    my $report_header = {};
116
    my $report_header = {};
117
    foreach my $biblionumber ($ref_biblionumber, @biblionumbers) {
117
    foreach my $biblionumber ($ref_biblionumber, @biblionumbers) {
118
        # build report
118
        # build report
119
        my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
119
        my $biblio = Koha::Biblios->find($biblionumber);
120
        my $marcrecord = $biblio->metadata->record;
120
        my %report_record = (
121
        my %report_record = (
121
            biblionumber => $biblionumber,
122
            biblionumber => $biblionumber,
122
            fields => {},
123
            fields => {},
Lines 204-210 if ($merge) { Link Here
204
        # Creating a loop for display
205
        # Creating a loop for display
205
        my @records;
206
        my @records;
206
        foreach my $biblionumber (@biblionumbers) {
207
        foreach my $biblionumber (@biblionumbers) {
207
            my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
208
            my $biblio = Koha::Biblios->find($biblionumber);
209
            my $marcrecord = $biblio->metadata->record;
208
            my $frameworkcode = GetFrameworkCode($biblionumber);
210
            my $frameworkcode = GetFrameworkCode($biblionumber);
209
            my $recordObj = Koha::MetadataRecord->new({'record' => $marcrecord, schema => $marcflavour});
211
            my $recordObj = Koha::MetadataRecord->new({'record' => $marcrecord, schema => $marcflavour});
210
            my $record = {
212
            my $record = {
(-)a/cataloguing/value_builder/marc21_linking_section.pl (-2 / +4 lines)
Lines 28-35 use C4::Search qw( new_record_from_zebra ); Link Here
28
use C4::Auth qw( get_template_and_user );
28
use C4::Auth qw( get_template_and_user );
29
use C4::Output qw( output_html_with_http_headers );
29
use C4::Output qw( output_html_with_http_headers );
30
30
31
use C4::Biblio qw( GetMarcBiblio TransformMarcToKoha );
31
use C4::Biblio qw( TransformMarcToKoha );
32
32
33
use Koha::Biblios;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
35
35
use Koha::SearchEngine;
36
use Koha::SearchEngine;
Lines 81-87 my $launcher = sub { Link Here
81
        );
82
        );
82
83
83
        #get marc record
84
        #get marc record
84
        $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
85
        my $biblio = Koha::Biblios->find($biblionumber);
86
        $marcrecord = $biblio->metadata->record;
85
87
86
        my $subfield_value_9 = $biblionumber;
88
        my $subfield_value_9 = $biblionumber;
87
        my $subfield_value_0 = $biblionumber;
89
        my $subfield_value_0 = $biblionumber;
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-2 / +4 lines)
Lines 28-35 use C4::Search qw( new_record_from_zebra ); Link Here
28
use C4::Auth qw( get_template_and_user );
28
use C4::Auth qw( get_template_and_user );
29
use C4::Output qw( output_html_with_http_headers );
29
use C4::Output qw( output_html_with_http_headers );
30
30
31
use C4::Biblio qw( GetMarcBiblio TransformMarcToKoha );
31
use C4::Biblio qw( TransformMarcToKoha );
32
32
33
use Koha::Biblios;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
35
35
use Koha::SearchEngine;
36
use Koha::SearchEngine;
Lines 92-98 sub plugin { Link Here
92
        );
93
        );
93
94
94
        #get marc record
95
        #get marc record
95
        $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
96
        my $biblio = Koha::Biblios->find($biblionumber);
97
        $marcrecord = $biblio->metadata->record;
96
98
97
        my $subfield_value_9 = $biblionumber;
99
        my $subfield_value_9 = $biblionumber;
98
        my $subfield_value_0;
100
        my $subfield_value_0;
(-)a/misc/add_date_fields_to_marc_records.pl (-2 / +3 lines)
Lines 24-29 use Pod::Usage qw( pod2usage ); Link Here
24
use MARC::Field;
24
use MARC::Field;
25
25
26
use C4::Biblio;
26
use C4::Biblio;
27
use Koha::Biblios;
27
use Koha::DateUtils qw( dt_from_string );
28
use Koha::DateUtils qw( dt_from_string );
28
29
29
my ( $verbose, $help, $confirm, $where, @fields, $unless_exists_field );
30
my ( $verbose, $help, $confirm, $where, @fields, $unless_exists_field );
Lines 62-69 my $sth = Link Here
62
$sth->execute();
63
$sth->execute();
63
64
64
while ( my ( $biblionumber, $frameworkcode ) = $sth->fetchrow_array ) {
65
while ( my ( $biblionumber, $frameworkcode ) = $sth->fetchrow_array ) {
65
    my $marc_record =
66
    my $biblio = Koha::Biblios->find($biblionumber);
66
      C4::Biblio::GetMarcBiblio( { biblionumber => $biblionumber } );
67
    my $marc_record = $biblio->metadata->record;
67
    next unless $marc_record;
68
    next unless $marc_record;
68
    if ( $unless_exists_field ) {
69
    if ( $unless_exists_field ) {
69
        my ( $tag,  $subfield ) = split '\$', $unless_exists_field;
70
        my ( $tag,  $subfield ) = split '\$', $unless_exists_field;
(-)a/misc/batchRepairMissingBiblionumbers.pl (-2 / +4 lines)
Lines 8-14 use warnings; Link Here
8
# Koha modules used
8
# Koha modules used
9
use Koha::Script;
9
use Koha::Script;
10
use C4::Context;
10
use C4::Context;
11
use C4::Biblio qw( GetMarcBiblio ModBiblioMarc );
11
use C4::Biblio qw( ModBiblioMarc );
12
use Koha::Biblios;
12
13
13
14
14
my $dbh = C4::Context->dbh;
15
my $dbh = C4::Context->dbh;
Lines 17-23 my $sth=$dbh->prepare("SELECT biblio.biblionumber, biblioitemnumber, frameworkco Link Here
17
$sth->execute();
18
$sth->execute();
18
19
19
while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){
20
while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){
20
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
21
    my $biblio = Koha::Biblios->find($biblionumber);
22
    my $record = $biblio->metadata->record;
21
    C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
23
    C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
22
    my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber )};
24
    my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber )};
23
    if($@){
25
    if($@){
(-)a/misc/cronjobs/check-url-quick.pl (-2 / +3 lines)
Lines 23-29 use Getopt::Long qw( GetOptions ); Link Here
23
23
24
use Koha::Script -cron;
24
use Koha::Script -cron;
25
use C4::Context;
25
use C4::Context;
26
use C4::Biblio qw( GetMarcBiblio );
26
use Koha::Biblios;
27
use AnyEvent;
27
use AnyEvent;
28
use AnyEvent::HTTP qw( http_request );
28
use AnyEvent::HTTP qw( http_request );
29
use Encode qw( encode_utf8 );
29
use Encode qw( encode_utf8 );
Lines 93-99 sub check_all_url { Link Here
93
        cb       => sub {
93
        cb       => sub {
94
            return if $count > $maxconn;
94
            return if $count > $maxconn;
95
            while ( my ($biblionumber) = $sth->fetchrow ) {
95
            while ( my ($biblionumber) = $sth->fetchrow ) {
96
                my $record = GetMarcBiblio({ biblionumber => $biblionumber });
96
                my $biblio = Koha::Biblios->find($biblionumber);
97
                my $record = $biblio->metadata->record;
97
                for my $tag (@tags) {
98
                for my $tag (@tags) {
98
                    foreach my $field ( $record->field($tag) ) {
99
                    foreach my $field ( $record->field($tag) ) {
99
                        my $url = $field->subfield('u');
100
                        my $url = $field->subfield('u');
(-)a/misc/link_bibs_to_authorities.pl (-6 / +7 lines)
Lines 7-16 use Koha::Script; Link Here
7
use C4::Context;
7
use C4::Context;
8
use C4::Biblio qw(
8
use C4::Biblio qw(
9
    GetFrameworkCode
9
    GetFrameworkCode
10
    GetMarcBiblio
11
    LinkBibHeadingsToAuthorities
10
    LinkBibHeadingsToAuthorities
12
    ModBiblio
11
    ModBiblio
13
);
12
);
13
use Koha::Biblios;
14
use Getopt::Long qw( GetOptions );
14
use Getopt::Long qw( GetOptions );
15
use Pod::Usage qw( pod2usage );
15
use Pod::Usage qw( pod2usage );
16
use Time::HiRes qw( time );
16
use Time::HiRes qw( time );
Lines 192-199 sub process_bib { Link Here
192
    my $args = shift;
192
    my $args = shift;
193
    my $tagtolink    = $args->{tagtolink};
193
    my $tagtolink    = $args->{tagtolink};
194
    my $allowrelink = $args->{allowrelink};
194
    my $allowrelink = $args->{allowrelink};
195
    my $bib = GetMarcBiblio({ biblionumber => $biblionumber });
195
    my $biblio = Koha::Biblios->find($biblionumber);
196
    unless ( defined $bib ) {
196
    my $record = $biblio->metadata->record;
197
    unless ( defined $record ) {
197
        print
198
        print
198
"\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n";
199
"\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n";
199
        $num_bad_bibs++;
200
        $num_bad_bibs++;
Lines 203-209 sub process_bib { Link Here
203
    my $frameworkcode = GetFrameworkCode($biblionumber);
204
    my $frameworkcode = GetFrameworkCode($biblionumber);
204
205
205
    my ( $headings_changed, $results ) =
206
    my ( $headings_changed, $results ) =
206
      LinkBibHeadingsToAuthorities( $linker, $bib, $frameworkcode, $allowrelink, $tagtolink );
207
      LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode, $allowrelink, $tagtolink );
207
    foreach my $key ( keys %{ $results->{'unlinked'} } ) {
208
    foreach my $key ( keys %{ $results->{'unlinked'} } ) {
208
        $unlinked_headings{$key} += $results->{'unlinked'}->{$key};
209
        $unlinked_headings{$key} += $results->{'unlinked'}->{$key};
209
    }
210
    }
Lines 216-222 sub process_bib { Link Here
216
217
217
    if ($headings_changed) {
218
    if ($headings_changed) {
218
        if ($verbose) {
219
        if ($verbose) {
219
            my $title = substr( $bib->title, 0, 20 );
220
            my $title = substr( $record->title, 0, 20 );
220
            printf(
221
            printf(
221
                "Bib %12d (%-20s): %3d headings changed\n",
222
                "Bib %12d (%-20s): %3d headings changed\n",
222
                $biblionumber,
223
                $biblionumber,
Lines 225-231 sub process_bib { Link Here
225
            );
226
            );
226
        }
227
        }
227
        if ( not $test_only ) {
228
        if ( not $test_only ) {
228
            ModBiblio( $bib, $biblionumber, $frameworkcode, { disable_autolink => 1 });
229
            ModBiblio( $record, $biblionumber, $frameworkcode, { disable_autolink => 1 });
229
            #Last param is to note ModBiblio was called from linking script and bib should not be linked again
230
            #Last param is to note ModBiblio was called from linking script and bib should not be linked again
230
            $num_bibs_modified++;
231
            $num_bibs_modified++;
231
        }
232
        }
(-)a/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl (-3 / +5 lines)
Lines 8-14 use strict; Link Here
8
use warnings;
8
use warnings;
9
9
10
use Koha::Script;
10
use Koha::Script;
11
use C4::Biblio qw( GetMarcBiblio ModBiblio );
11
use C4::Biblio qw( ModBiblio );
12
use Koha::Biblios;
12
use Getopt::Long qw( GetOptions );
13
use Getopt::Long qw( GetOptions );
13
14
14
sub _read_marc_code {
15
sub _read_marc_code {
Lines 83-92 my $sth_prepared; Link Here
83
84
84
sub updateMarc {
85
sub updateMarc {
85
    my $id     = shift;
86
    my $id     = shift;
86
    my $biblio = GetMarcBiblio({ biblionumber => $id });
87
    my $biblio = Koha::Biblios->find($id);
88
    $biblio  &&= $biblio->metadata->record;
87
89
88
    unless ($biblio) {
90
    unless ($biblio) {
89
        $debug and warn '[ERROR] GetMarcBiblio did not return any biblio.';
91
        $debug and warn '[ERROR] Biblio not found.';
90
        return;
92
        return;
91
    }
93
    }
92
94
(-)a/misc/maintenance/process_record_through_filter.pl (-2 / +7 lines)
Lines 8-17 use strict; Link Here
8
use warnings;
8
use warnings;
9
9
10
use Koha::Script;
10
use Koha::Script;
11
use Koha::Biblios;
11
use Koha::RecordProcessor;
12
use Koha::RecordProcessor;
12
use C4::Biblio qw( GetMarcBiblio );
13
13
14
my $record = GetMarcBiblio({ biblionumber => $ARGV[0] });
14
my $biblio = Koha::Biblios->find($ARGV[0]);
15
unless ( $biblio ) {
16
    print "Biblio not found\n";
17
    exit;
18
}
19
my $record = $biblio->metadata->record;
15
20
16
print "Before: " . $record->as_formatted() . "\n";
21
print "Before: " . $record->as_formatted() . "\n";
17
my $processor = Koha::RecordProcessor->new( { filters => ( $ARGV[1] ) });
22
my $processor = Koha::RecordProcessor->new( { filters => ( $ARGV[1] ) });
(-)a/misc/maintenance/remove_items_from_biblioitems.pl (-3 / +5 lines)
Lines 24-30 $|=1; Link Here
24
24
25
use Koha::Script;
25
use Koha::Script;
26
use C4::Context;
26
use C4::Context;
27
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblio );
27
use C4::Biblio qw( GetFrameworkCode ModBiblio );
28
use Koha::Biblios;
28
use Getopt::Long qw( GetOptions );
29
use Getopt::Long qw( GetOptions );
29
30
30
my ($wherestring, $run, $silent, $want_help);
31
my ($wherestring, $run, $silent, $want_help);
Lines 50-57 while (my $biblionumber = $query->fetchrow){ Link Here
50
    $count++;
51
    $count++;
51
    print "." unless $silent;
52
    print "." unless $silent;
52
    print "\r$count" unless ($silent or ($count % 100)); 
53
    print "\r$count" unless ($silent or ($count % 100)); 
53
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
54
    my $biblio = Koha::Biblios->find($biblionumber);
54
    
55
    my $record = $biblio->metadata->record;
56
55
    if ($record) {
57
    if ($record) {
56
        ModBiblio($record, $biblionumber, GetFrameworkCode($biblionumber)) ;
58
        ModBiblio($record, $biblionumber, GetFrameworkCode($biblionumber)) ;
57
    }
59
    }
(-)a/misc/maintenance/sanitize_records.pl (-1 / +7 lines)
Lines 23-28 use Koha::Script; Link Here
23
use C4::Charset;
23
use C4::Charset;
24
use C4::Context;
24
use C4::Context;
25
use C4::Biblio;
25
use C4::Biblio;
26
use Koha::Biblios;
26
use Getopt::Long qw( GetOptions );
27
use Getopt::Long qw( GetOptions );
27
use Pod::Usage qw( pod2usage );
28
use Pod::Usage qw( pod2usage );
28
29
Lines 109-115 for my $biblionumber (@biblionumbers) { Link Here
109
        say " skipping. ERROR: Invalid biblionumber." if $verbose;
110
        say " skipping. ERROR: Invalid biblionumber." if $verbose;
110
        next;
111
        next;
111
    }
112
    }
112
    my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
113
    my $biblio = Koha::Biblios->find($biblionumber);
114
    unless ( $biblio ) {
115
        say " skipping. ERROR: biblionumber not found." if $verbose;
116
        next;
117
    }
118
    my $record = $biblio->metadata->record;
113
    unless ($record) {
119
    unless ($record) {
114
        say " skipping. ERROR: Invalid record." if $verbose;
120
        say " skipping. ERROR: Invalid record." if $verbose;
115
        next;
121
        next;
(-)a/misc/maintenance/touch_all_biblios.pl (-3 / +5 lines)
Lines 25-31 use Getopt::Long qw( GetOptions ); Link Here
25
25
26
use Koha::Script;
26
use Koha::Script;
27
use C4::Context;
27
use C4::Context;
28
use C4::Biblio qw( GetMarcBiblio ModBiblio );
28
use C4::Biblio qw( ModBiblio );
29
use Koha::Biblios;
29
use Pod::Usage qw( pod2usage );
30
use Pod::Usage qw( pod2usage );
30
31
31
32
Lines 75-82 $sth1->execute(); Link Here
75
76
76
# fetch info from the search
77
# fetch info from the search
77
while (my ($biblionumber, $frameworkcode) = $sth1->fetchrow_array){
78
while (my ($biblionumber, $frameworkcode) = $sth1->fetchrow_array){
78
  my $record = GetMarcBiblio({ biblionumber => $biblionumber });
79
  my $biblio = Koha::Biblios->find($biblionumber);
79
 
80
  my $record = $biblio->metadata->record;
81
80
  my $modok = ModBiblio($record, $biblionumber, $frameworkcode);
82
  my $modok = ModBiblio($record, $biblionumber, $frameworkcode);
81
83
82
  if ($modok) {
84
  if ($modok) {
(-)a/misc/migration_tools/22_to_30/missing090field.pl (-2 / +4 lines)
Lines 8-14 use strict; Link Here
8
# Koha modules used
8
# Koha modules used
9
9
10
use C4::Context;
10
use C4::Context;
11
use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ModBiblioMarc );
11
use C4::Biblio qw( GetMarcFromKohaField ModBiblioMarc );
12
use Koha::Biblios;
12
use MARC::File::USMARC;
13
use MARC::File::USMARC;
13
14
14
$|=1;
15
$|=1;
Lines 19-25 $sth->execute(); Link Here
19
20
20
my $i=1;
21
my $i=1;
21
while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){
22
while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){
22
 my $record = GetMarcBiblio({ biblionumber => $biblionumber });
23
 my $biblio = Koha::Biblios->find($biblionumber);
24
 my $record = $biblio->metadata->record;
23
    print ".";
25
    print ".";
24
    print "\r$i" unless $i %100;
26
    print "\r$i" unless $i %100;
25
    MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record);
27
    MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record);
(-)a/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl (-2 / +4 lines)
Lines 8-14 use strict; Link Here
8
# Koha modules used
8
# Koha modules used
9
9
10
use C4::Context;
10
use C4::Context;
11
use C4::Biblio qw( GetMarcBiblio ModBiblioMarc );
11
use C4::Biblio qw( ModBiblioMarc );
12
use Koha::Biblios;
12
use MARC::File::USMARC;
13
use MARC::File::USMARC;
13
14
14
15
Lines 22-28 print "Creating/updating field 100 if needed\n"; Link Here
22
while (my ($biblionumber,$time)=$sth->fetchrow ){
23
while (my ($biblionumber,$time)=$sth->fetchrow ){
23
#   my $record;
24
#   my $record;
24
# print "record : $biblionumber \n";
25
# print "record : $biblionumber \n";
25
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
26
    my $biblio = Koha::Biblios->find($biblionumber);
27
    my $record = $biblio ? $biblio->metadata->record : undef;
26
# print "=> ".$record->as_formatted;
28
# print "=> ".$record->as_formatted;
27
    MARCmodrecord($biblionumber,$record,$time) if ($record);
29
    MARCmodrecord($biblionumber,$record,$time) if ($record);
28
#
30
#
(-)a/misc/migration_tools/buildEDITORS.pl (-2 / +3 lines)
Lines 10-17 use MARC::Record; Link Here
10
use MARC::Batch;
10
use MARC::Batch;
11
use Koha::Script;
11
use Koha::Script;
12
use C4::Context;
12
use C4::Context;
13
use C4::Biblio qw( GetMarcBiblio );
14
use C4::AuthoritiesMarc;
13
use C4::AuthoritiesMarc;
14
use Koha::Biblios;
15
use Time::HiRes qw( gettimeofday );
15
use Time::HiRes qw( gettimeofday );
16
16
17
use Getopt::Long qw( GetOptions );
17
use Getopt::Long qw( GetOptions );
Lines 70-76 my $i=1; Link Here
70
my $counter;
70
my $counter;
71
my %hash;
71
my %hash;
72
while (my ($bibid) = $sth->fetchrow) {
72
while (my ($bibid) = $sth->fetchrow) {
73
    my $record = GetMarcBiblio({ biblionumber => $bibid });
73
    my $biblio = Koha::Biblios->find($bibid);
74
    my $record = $biblio->metadata->record;
74
	my $isbnField = $record->field('010');
75
	my $isbnField = $record->field('010');
75
	next unless $isbnField;
76
	next unless $isbnField;
76
	my $isbn=$isbnField->subfield('a');
77
	my $isbn=$isbnField->subfield('a');
(-)a/misc/migration_tools/create_analytical_rel.pl (-5 / +7 lines)
Lines 5-12 use strict; Link Here
5
5
6
use Koha::Script;
6
use Koha::Script;
7
use C4::Context;
7
use C4::Context;
8
use C4::Biblio qw( GetMarcBiblio ModBiblio );
8
use C4::Biblio qw( ModBiblio );
9
use Koha::Items;
9
use Koha::Items;
10
use Koha::Biblios;
10
use Getopt::Long qw( GetOptions );
11
use Getopt::Long qw( GetOptions );
11
12
12
$| = 1;
13
$| = 1;
Lines 75-89 _SUMMARY_ Link Here
75
sub process_bib {
76
sub process_bib {
76
    my $biblionumber = shift;
77
    my $biblionumber = shift;
77
78
78
    my $bib = GetMarcBiblio({ biblionumber => $biblionumber });
79
    my $biblio = Koha::Biblios->find($biblionumber);
79
    unless (defined $bib) {
80
    my $record = $biblio->metadata->record;
81
    unless (defined $record) {
80
        print "\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n";
82
        print "\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n";
81
        $num_bad_bibs++;
83
        $num_bad_bibs++;
82
        return;
84
        return;
83
    }
85
    }
84
	#loop through each host field and populate subfield 0 and 9
86
	#loop through each host field and populate subfield 0 and 9
85
    my $analyticfield = '773';
87
    my $analyticfield = '773';
86
	foreach my $hostfield ( $bib->field($analyticfield) ) {
88
    foreach my $hostfield ( $record->field($analyticfield) ) {
87
		if(my $barcode = $hostfield->subfield('o')){
89
		if(my $barcode = $hostfield->subfield('o')){
88
            my $item = Koha::Items->find({ barcode => $barcode });
90
            my $item = Koha::Items->find({ barcode => $barcode });
89
            if ($item) {
91
            if ($item) {
Lines 98-104 sub process_bib { Link Here
98
                }
100
                }
99
                if ($modif) {
101
                if ($modif) {
100
                    $num_bibs_modified++;
102
                    $num_bibs_modified++;
101
                    my $modresult = ModBiblio( $bib, $biblionumber, '' );
103
                    my $modresult = ModBiblio( $record, $biblionumber, '' );
102
                    warn "Modifying biblio $biblionumber";
104
                    warn "Modifying biblio $biblionumber";
103
                    if ( !$modresult ) {
105
                    if ( !$modresult ) {
104
                        warn "Unable to modify biblio $biblionumber with update host field";
106
                        warn "Unable to modify biblio $biblionumber with update host field";
(-)a/misc/migration_tools/import_lexile.pl (-2 / +3 lines)
Lines 33-39 use Text::CSV; Link Here
33
33
34
use Koha::Script;
34
use Koha::Script;
35
use C4::Context;
35
use C4::Context;
36
use C4::Biblio qw( GetMarcBiblio ModBiblio );
36
use C4::Biblio qw( ModBiblio );
37
use C4::Koha qw( GetVariationsOfISBN );
37
use C4::Koha qw( GetVariationsOfISBN );
38
38
39
use Koha::Biblios;
39
use Koha::Biblios;
Lines 145-151 while ( my $row = $csv->getline_hr($fh) ) { Link Here
145
145
146
    foreach my $biblionumber (@biblionumbers) {
146
    foreach my $biblionumber (@biblionumbers) {
147
        $counter++;
147
        $counter++;
148
        my $record = GetMarcBiblio({ biblionumber => $biblionumber });
148
        my $biblio = Koha::Biblios->find($biblionumber);
149
        my $record = $biblio->metadata->record;
149
150
150
        if ($verbose) {
151
        if ($verbose) {
151
            say "Found matching record! Biblionumber: $biblionumber";
152
            say "Found matching record! Biblionumber: $biblionumber";
(-)a/misc/migration_tools/switch_marc21_series_info.pl (-2 / +4 lines)
Lines 23-30 use warnings; Link Here
23
# Script to switch the MARC21 440$anv and 490$av information
23
# Script to switch the MARC21 440$anv and 490$av information
24
24
25
use Koha::Script;
25
use Koha::Script;
26
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblioMarc );
26
use C4::Biblio qw( GetFrameworkCode ModBiblioMarc );
27
use C4::Context;
27
use C4::Context;
28
use Koha::Biblios;
28
use Getopt::Long qw( GetOptions );
29
use Getopt::Long qw( GetOptions );
29
30
30
my $commit;
31
my $commit;
Lines 133-139 while ( my ( $biblionumber ) = $bibs_sth->fetchrow ) { Link Here
133
    my ( @newfields );
134
    my ( @newfields );
134
135
135
    # Get biblio marc
136
    # Get biblio marc
136
    my $biblio = GetMarcBiblio({ biblionumber => $biblionumber });
137
    my $biblio = Koha::Biblios->find($biblionumber);
138
    $biblio  &&= $biblio->metadata->record;
137
139
138
    foreach my $field ( $biblio->field( '440' ) ) {
140
    foreach my $field ( $biblio->field( '440' ) ) {
139
        my @newsubfields;
141
        my @newsubfields;
(-)a/misc/migration_tools/upgradeitems.pl (-2 / +3 lines)
Lines 6-12 use strict; Link Here
6
use Koha::Script;
6
use Koha::Script;
7
use C4::Context;
7
use C4::Context;
8
use C4::Items qw( ModItemFromMarc );
8
use C4::Items qw( ModItemFromMarc );
9
use C4::Biblio qw( GetMarcBiblio );
9
use Koha::Biblios;
10
10
11
my $dbh=C4::Context->dbh;
11
my $dbh=C4::Context->dbh;
12
12
Lines 20-26 my $rqitemnumber=$dbh->prepare("SELECT itemnumber, biblionumber from items where Link Here
20
$rqbiblios->execute;
20
$rqbiblios->execute;
21
$|=1;
21
$|=1;
22
while (my ($biblionumber)= $rqbiblios->fetchrow_array){
22
while (my ($biblionumber)= $rqbiblios->fetchrow_array){
23
    my $record=GetMarcBiblio({ biblionumber => $biblionumber });
23
    my $biblio = Koha::Biblios->find($biblionumber);
24
    my $record = $biblio->metadata->record;
24
    foreach my $itemfield ($record->field('995')){
25
    foreach my $itemfield ($record->field('995')){
25
        my $marcitem=MARC::Record->new();
26
        my $marcitem=MARC::Record->new();
26
        $marcitem->encoding('UTF-8');
27
        $marcitem->encoding('UTF-8');
(-)a/opac/opac-basket.pl (-2 / +1 lines)
Lines 22-28 use CGI qw ( -utf8 ); Link Here
22
use C4::Koha;
22
use C4::Koha;
23
use C4::Biblio qw(
23
use C4::Biblio qw(
24
    GetFrameworkCode
24
    GetFrameworkCode
25
    GetMarcBiblio
26
    GetMarcSeries
25
    GetMarcSeries
27
    GetMarcSubjects
26
    GetMarcSubjects
28
    GetMarcUrls
27
    GetMarcUrls
Lines 82-88 foreach my $biblionumber ( @bibs ) { Link Here
82
81
83
    # No filtering on the item records needed for the record itself
82
    # No filtering on the item records needed for the record itself
84
    # since the only reason item information is grabbed is because of branchcodes.
83
    # since the only reason item information is grabbed is because of branchcodes.
85
    my $record = &GetMarcBiblio({ biblionumber => $biblionumber });
84
    my $record = $biblio->metadata->record;
86
    my $framework = &GetFrameworkCode( $biblionumber );
85
    my $framework = &GetFrameworkCode( $biblionumber );
87
    $record_processor->options({
86
    $record_processor->options({
88
        interface => 'opac',
87
        interface => 'opac',
(-)a/opac/opac-reserve.pl (-5 / +5 lines)
Lines 25-31 use C4::Auth qw( get_template_and_user ); Link Here
25
use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
25
use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
26
use C4::Circulation qw( GetBranchItemRule GetTransfers );
26
use C4::Circulation qw( GetBranchItemRule GetTransfers );
27
use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
27
use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
28
use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
28
use C4::Biblio qw( GetBiblioData GetFrameworkCode );
29
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
29
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
30
use C4::Output qw( output_html_with_http_headers );
30
use C4::Output qw( output_html_with_http_headers );
31
use C4::Context;
31
use C4::Context;
Lines 150-156 foreach my $biblioNumber (@biblionumbers) { Link Here
150
150
151
    my @itemInfos = GetItemsInfo($biblioNumber);
151
    my @itemInfos = GetItemsInfo($biblioNumber);
152
152
153
    my $marcrecord= GetMarcBiblio({ biblionumber => $biblioNumber });
153
    my $biblio = Koha::Biblios->find( $biblioNumber );
154
    next unless $biblio;
155
156
    my $marcrecord = $biblio->metadata->record;
154
157
155
    # flag indicating existence of at least one item linked via a host record
158
    # flag indicating existence of at least one item linked via a host record
156
    # adding items linked via host biblios
159
    # adding items linked via host biblios
Lines 165-173 foreach my $biblioNumber (@biblionumbers) { Link Here
165
    }
168
    }
166
169
167
    # Compute the priority rank.
170
    # Compute the priority rank.
168
    my $biblio = Koha::Biblios->find( $biblioNumber );
169
    next unless $biblio;
170
171
    $biblioData->{object} = $biblio;
171
    $biblioData->{object} = $biblio;
172
    my $holds = $biblio->holds;
172
    my $holds = $biblio->holds;
173
    my $rank = $holds->count;
173
    my $rank = $holds->count;
(-)a/opac/opac-shelves.pl (-5 / +6 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Auth qw( get_template_and_user );
23
use C4::Auth qw( get_template_and_user );
24
use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
24
use C4::Biblio qw( GetBiblioData GetFrameworkCode );
25
use C4::External::BakerTaylor qw( image_url link_url );
25
use C4::External::BakerTaylor qw( image_url link_url );
26
use C4::Koha qw(
26
use C4::Koha qw(
27
    GetNormalizedEAN
27
    GetNormalizedEAN
Lines 317-326 if ( $op eq 'view' ) { Link Here
317
            while ( my $content = $contents->next ) {
317
            while ( my $content = $contents->next ) {
318
                my $biblionumber = $content->biblionumber;
318
                my $biblionumber = $content->biblionumber;
319
                my $this_item    = GetBiblioData($biblionumber);
319
                my $this_item    = GetBiblioData($biblionumber);
320
                my $record = GetMarcBiblio({ biblionumber => $biblionumber });
320
                my $biblio       = Koha::Biblios->find($biblionumber);
321
                my $framework = GetFrameworkCode( $biblionumber );
321
                my $record       = $biblio->metadata->record;
322
                my $biblio = Koha::Biblios->find( $biblionumber );
322
                my $framework    = GetFrameworkCode($biblionumber);
323
                $record_processor->options({
323
                $record_processor->options(
324
                    {
324
                    interface => 'opac',
325
                    interface => 'opac',
325
                    frameworkcode => $framework
326
                    frameworkcode => $framework
326
                });
327
                });
(-)a/opac/opac-showreviews.pl (-2 / +2 lines)
Lines 29-36 use C4::Koha qw( Link Here
29
    GetNormalizedUPC
29
    GetNormalizedUPC
30
);
30
);
31
use C4::Output qw( output_html_with_http_headers );
31
use C4::Output qw( output_html_with_http_headers );
32
use C4::Biblio qw( GetMarcBiblio );
33
use Koha::DateUtils qw( dt_from_string );
32
use Koha::DateUtils qw( dt_from_string );
33
use Koha::Biblios;
34
use Koha::Patrons;
34
use Koha::Patrons;
35
use Koha::Reviews;
35
use Koha::Reviews;
36
use POSIX qw( ceil floor );
36
use POSIX qw( ceil floor );
Lines 93-99 for my $result (@$reviews){ Link Here
93
    my $biblionumber = $result->{biblionumber};
93
    my $biblionumber = $result->{biblionumber};
94
    my $biblio = Koha::Biblios->find( $biblionumber );
94
    my $biblio = Koha::Biblios->find( $biblionumber );
95
    my $biblioitem = $biblio->biblioitem;
95
    my $biblioitem = $biblio->biblioitem;
96
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
96
    my $record = $biblio->metadata->record;
97
	$result->{normalized_upc} = GetNormalizedUPC($record,$marcflavour);
97
	$result->{normalized_upc} = GetNormalizedUPC($record,$marcflavour);
98
	$result->{normalized_ean} = GetNormalizedEAN($record,$marcflavour);
98
	$result->{normalized_ean} = GetNormalizedEAN($record,$marcflavour);
99
	$result->{normalized_oclc} = GetNormalizedOCLCNumber($record,$marcflavour);
99
	$result->{normalized_oclc} = GetNormalizedOCLCNumber($record,$marcflavour);
(-)a/opac/tracklinks.pl (-1 / +3 lines)
Lines 23-28 use C4::Context; Link Here
23
use C4::Auth qw( checkauth );
23
use C4::Auth qw( checkauth );
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Output qw( output_error );
25
use C4::Output qw( output_error );
26
use Koha::Biblios;
26
use Koha::Items;
27
use Koha::Items;
27
use Koha::Linktracker;
28
use Koha::Linktracker;
28
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
Lines 59-65 if ($uri && ($biblionumber || $itemnumber) ) { Link Here
59
        # get borrower info
60
        # get borrower info
60
    }
61
    }
61
62
62
    my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
63
    my $biblio = Koha::Biblios->find($biblionumber);
64
    my $record = $biblio->metadata->record;
63
    my $marc_urls = $record ? C4::Biblio::GetMarcUrls($record, C4::Context->preference('marcflavour')) : [];
65
    my $marc_urls = $record ? C4::Biblio::GetMarcUrls($record, C4::Context->preference('marcflavour')) : [];
64
    my $search_crit = { uri => { -like => "%$uri%" } };
66
    my $search_crit = { uri => { -like => "%$uri%" } };
65
    if( $itemnumber ) { # itemnumber is leading over biblionumber
67
    if( $itemnumber ) { # itemnumber is leading over biblionumber
(-)a/t/db_dependent/Authority/Merge.t (-17 / +18 lines)
Lines 13-22 use Test::MockModule; Link Here
13
use t::lib::Mocks;
13
use t::lib::Mocks;
14
use t::lib::TestBuilder;
14
use t::lib::TestBuilder;
15
15
16
use C4::Biblio qw( AddBiblio GetMarcBiblio ModBiblio );
16
use C4::Biblio qw( AddBiblio ModBiblio );
17
use Koha::Authorities;
17
use Koha::Authorities;
18
use Koha::Authority::ControlledIndicators;
18
use Koha::Authority::ControlledIndicators;
19
use Koha::Authority::MergeRequests;
19
use Koha::Authority::MergeRequests;
20
use Koha::Biblios;
20
use Koha::Database;
21
use Koha::Database;
21
22
22
BEGIN {
23
BEGIN {
Lines 95-107 subtest 'Test merge A1 to A2 (within same authtype)' => sub { Link Here
95
    is( $rv, 1, 'We expect one biblio record (out of two) to be updated' );
96
    is( $rv, 1, 'We expect one biblio record (out of two) to be updated' );
96
97
97
    # Check the results
98
    # Check the results
98
    my $newbiblio1 = GetMarcBiblio({ biblionumber => $biblionumber1 });
99
    my $newbiblio1 = Koha::Biblios->find($biblionumber1)->metadata->record;
99
    compare_fields( $biblio1, $newbiblio1, {}, 'count' );
100
    compare_fields( $biblio1, $newbiblio1, {}, 'count' );
100
    compare_fields( $biblio1, $newbiblio1, {}, 'order' );
101
    compare_fields( $biblio1, $newbiblio1, {}, 'order' );
101
    is( $newbiblio1->subfield('609', '9'), $authid1, 'Check biblio1 609$9' );
102
    is( $newbiblio1->subfield('609', '9'), $authid1, 'Check biblio1 609$9' );
102
    is( $newbiblio1->subfield('609', 'a'), 'George Orwell',
103
    is( $newbiblio1->subfield('609', 'a'), 'George Orwell',
103
        'Check biblio1 609$a' );
104
        'Check biblio1 609$a' );
104
    my $newbiblio2 = GetMarcBiblio({ biblionumber => $biblionumber2 });
105
    my $newbiblio2 = Koha::Biblios->find($biblionumber2)->metadata->record;
105
    compare_fields( $biblio2, $newbiblio2, {}, 'count' );
106
    compare_fields( $biblio2, $newbiblio2, {}, 'count' );
106
    compare_fields( $biblio2, $newbiblio2, {}, 'order' );
107
    compare_fields( $biblio2, $newbiblio2, {}, 'order' );
107
    is( $newbiblio2->subfield('609', '9'), $authid1, 'Check biblio2 609$9' );
108
    is( $newbiblio2->subfield('609', '9'), $authid1, 'Check biblio2 609$9' );
Lines 139-149 subtest 'Test merge A1 to modified A1, test strict mode' => sub { Link Here
139
    is( $rv, 2, 'Both records are updated now' );
140
    is( $rv, 2, 'Both records are updated now' );
140
141
141
    #Check the results
142
    #Check the results
142
    my $biblio1 = GetMarcBiblio({ biblionumber => $biblionumber1 });
143
    my $biblio1 = Koha::Biblios->find($biblionumber1)->metadata->record;
143
    compare_fields( $MARC1, $biblio1, {}, 'count' );
144
    compare_fields( $MARC1, $biblio1, {}, 'count' );
144
    compare_fields( $MARC1, $biblio1, {}, 'order' );
145
    compare_fields( $MARC1, $biblio1, {}, 'order' );
145
    is( $auth1new->field(109)->subfield('a'), $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' );
146
    is( $auth1new->field(109)->subfield('a'), $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' );
146
    my $biblio2 = GetMarcBiblio({ biblionumber => $biblionumber2 });
147
    my $biblio2 = Koha::Biblios->find($biblionumber2)->metadata->record;
147
    compare_fields( $MARC2, $biblio2, {}, 'count' );
148
    compare_fields( $MARC2, $biblio2, {}, 'count' );
148
    compare_fields( $MARC2, $biblio2, {}, 'order' );
149
    compare_fields( $MARC2, $biblio2, {}, 'order' );
149
    is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' );
150
    is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' );
Lines 155-161 subtest 'Test merge A1 to modified A1, test strict mode' => sub { Link Here
155
    ModBiblio( $MARC1, $biblionumber1, '' );
156
    ModBiblio( $MARC1, $biblionumber1, '' );
156
    @linkedrecords = ( $biblionumber1 );
157
    @linkedrecords = ( $biblionumber1 );
157
    $rv = C4::AuthoritiesMarc::merge({ mergefrom => $authid1, MARCfrom => $auth1old, mergeto => $authid1, MARCto => $auth1new });
158
    $rv = C4::AuthoritiesMarc::merge({ mergefrom => $authid1, MARCfrom => $auth1old, mergeto => $authid1, MARCto => $auth1new });
158
    $biblio1 = GetMarcBiblio({ biblionumber => $biblionumber1 });
159
    $biblio1 = Koha::Biblios->find($biblionumber1)->metadata->record;
159
    is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' );
160
    is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' );
160
    compare_fields( $MARC1, $biblio1, { 609 => 1 }, 'count' );
161
    compare_fields( $MARC1, $biblio1, { 609 => 1 }, 'count' );
161
    my @old609 = $MARC1->field('609');
162
    my @old609 = $MARC1->field('609');
Lines 196-202 subtest 'Test merge A1 to B1 (changing authtype)' => sub { Link Here
196
        MARC::Field->new( '612', '', '', a => 'unrelated', 9 => 'other' ),
197
        MARC::Field->new( '612', '', '', a => 'unrelated', 9 => 'other' ),
197
    );
198
    );
198
    my ( $biblionumber ) = C4::Biblio::AddBiblio( $marc, '' );
199
    my ( $biblionumber ) = C4::Biblio::AddBiblio( $marc, '' );
199
    my $oldbiblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
200
    my $oldbiblio = Koha::Biblios->find($biblionumber)->metadata->record;
200
201
201
    # Time to merge
202
    # Time to merge
202
    @linkedrecords = ( $biblionumber );
203
    @linkedrecords = ( $biblionumber );
Lines 204-210 subtest 'Test merge A1 to B1 (changing authtype)' => sub { Link Here
204
    is( $retval, 1, 'We touched only one biblio' );
205
    is( $retval, 1, 'We touched only one biblio' );
205
206
206
    # Get new marc record for compares
207
    # Get new marc record for compares
207
    my $newbiblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
208
    my $newbiblio = Koha::Biblios->find($biblionumber)->metadata->record;
208
    compare_fields( $oldbiblio, $newbiblio, {}, 'count' );
209
    compare_fields( $oldbiblio, $newbiblio, {}, 'count' );
209
    # Exclude 109/609 and 112/612 in comparing order
210
    # Exclude 109/609 and 112/612 in comparing order
210
    my $excl = { '109' => 1, '112' => 1, '609' => 1, '612' => 1 };
211
    my $excl = { '109' => 1, '112' => 1, '609' => 1, '612' => 1 };
Lines 261-267 subtest 'Merging authorities should handle deletes (BZ 18070)' => sub { Link Here
261
    DelAuthority({ authid => $authid1 }); # this triggers a merge call
262
    DelAuthority({ authid => $authid1 }); # this triggers a merge call
262
263
263
    # See what happened in the biblio record
264
    # See what happened in the biblio record
264
    my $marc1 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
265
    my $marc1 = Koha::Biblios->find($biblionumber)->metadata->record;
265
    is( $marc1->field('609'), undef, 'Field 609 should be gone too' );
266
    is( $marc1->field('609'), undef, 'Field 609 should be gone too' );
266
267
267
    # Now we simulate the delete as done in the cron job
268
    # Now we simulate the delete as done in the cron job
Lines 283-289 subtest 'Merging authorities should handle deletes (BZ 18070)' => sub { Link Here
283
    $mocks->{auth_mod}->unmock_all;
284
    $mocks->{auth_mod}->unmock_all;
284
    merge({ mergefrom => $authid1, biblionumbers => [ $biblionumber ] });
285
    merge({ mergefrom => $authid1, biblionumbers => [ $biblionumber ] });
285
    # Final check
286
    # Final check
286
    $marc1 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
287
    $marc1 = Koha::Biblios->find($biblionumber)->metadata->record;
287
    is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' );
288
    is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' );
288
};
289
};
289
290
Lines 307-320 subtest "Test some specific postponed merge issues" => sub { Link Here
307
    # This proves the !authtypefrom condition in sub merge
308
    # This proves the !authtypefrom condition in sub merge
308
    # Additionally, we test clearing subfield
309
    # Additionally, we test clearing subfield
309
    merge({ mergefrom => $id + 1, MARCfrom => $oldauthmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
310
    merge({ mergefrom => $id + 1, MARCfrom => $oldauthmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
310
    $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
311
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
311
    is( $biblio->subfield('609', '9'), $id, '612 moved to 609' );
312
    is( $biblio->subfield('609', '9'), $id, '612 moved to 609' );
312
    is( $biblio->subfield('609', 'c'), undef, '609c cleared correctly' );
313
    is( $biblio->subfield('609', 'c'), undef, '609c cleared correctly' );
313
314
314
    # Merge A to B postponed, delete B immediately (hits B < hits A)
315
    # Merge A to B postponed, delete B immediately (hits B < hits A)
315
    # This proves the !@record_to test in sub merge
316
    # This proves the !@record_to test in sub merge
316
    merge({ mergefrom => $id + 2, mergeto => $id + 1, MARCto => undef, biblionumbers => [ $biblionumber ] });
317
    merge({ mergefrom => $id + 2, mergeto => $id + 1, MARCto => undef, biblionumbers => [ $biblionumber ] });
317
    $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
318
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
318
    is( $biblio->field('612'), undef, 'Last 612 must be gone' );
319
    is( $biblio->field('612'), undef, 'Last 612 must be gone' );
319
320
320
    # Show that we 'need' skip_merge; this example is far-fetched.
321
    # Show that we 'need' skip_merge; this example is far-fetched.
Lines 326-332 subtest "Test some specific postponed merge issues" => sub { Link Here
326
    my $restored_mocks = set_mocks();
327
    my $restored_mocks = set_mocks();
327
    DelAuthority({ authid => $id, skip_merge => 1 }); # delete A
328
    DelAuthority({ authid => $id, skip_merge => 1 }); # delete A
328
    $restored_mocks->{auth_mod}->unmock_all;
329
    $restored_mocks->{auth_mod}->unmock_all;
329
    $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
330
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
330
    is( $biblio->subfield('109', '9'), $id, 'If the 109 is no longer present, another modify merge would not bring it back' );
331
    is( $biblio->subfield('109', '9'), $id, 'If the 109 is no longer present, another modify merge would not bring it back' );
331
332
332
    # Bug 22437 now removes older postponed A->A merges in DelAuthority
333
    # Bug 22437 now removes older postponed A->A merges in DelAuthority
Lines 367-373 subtest "Graceful resolution of missing reporting tag" => sub { Link Here
367
368
368
    # Merge
369
    # Merge
369
    merge({ mergefrom => $id1, MARCfrom => $authmarc, mergeto => $id2, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
370
    merge({ mergefrom => $id1, MARCfrom => $authmarc, mergeto => $id2, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
370
    $biblio = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
371
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
371
    is( $biblio->subfield('612', '9'), $id2, 'id2 saved in $9' );
372
    is( $biblio->subfield('612', '9'), $id2, 'id2 saved in $9' );
372
    is( $biblio->subfield('612', 'a'), ' ', 'Kept an empty $a too' );
373
    is( $biblio->subfield('612', 'a'), ' ', 'Kept an empty $a too' );
373
374
Lines 392-398 subtest 'merge should not reorder too much' => sub { Link Here
392
393
393
    # Merge 109 and 609 and check order of subfields
394
    # Merge 109 and 609 and check order of subfields
394
    merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
395
    merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
395
    my $biblio2 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
396
    my $biblio2 = Koha::Biblios->find($biblionumber)->metadata->record;
396
    my $subfields = [ map { $_->[0] } $biblio2->field('109')->subfields ];
397
    my $subfields = [ map { $_->[0] } $biblio2->field('109')->subfields ];
397
    is_deeply( $subfields, [ 'i', 'a', 'b', 'c', '9' ], 'Merge only moved $9' );
398
    is_deeply( $subfields, [ 'i', 'a', 'b', 'c', '9' ], 'Merge only moved $9' );
398
    $subfields = [ map { $_->[0] } $biblio2->field('609')->subfields ];
399
    $subfields = [ map { $_->[0] } $biblio2->field('609')->subfields ];
Lines 422-428 subtest 'Test how merge handles controlled indicators' => sub { Link Here
422
423
423
    # Merge and check indicators and $2
424
    # Merge and check indicators and $2
424
    merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
425
    merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
425
    my $biblio2 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
426
    my $biblio2 = Koha::Biblios->find($biblionumber)->metadata->record;
426
    is( $biblio2->field('609')->indicator(1), '7', 'Indicator1 OK' );
427
    is( $biblio2->field('609')->indicator(1), '7', 'Indicator1 OK' );
427
    is( $biblio2->field('609')->indicator(2), '7', 'Indicator2 OK' );
428
    is( $biblio2->field('609')->indicator(2), '7', 'Indicator2 OK' );
428
    is( $biblio2->subfield('609', '2'), 'aat', 'Subfield $2 OK' );
429
    is( $biblio2->subfield('609', '2'), 'aat', 'Subfield $2 OK' );
Lines 431-437 subtest 'Test how merge handles controlled indicators' => sub { Link Here
431
    $authmarc->field('008')->update( (' 'x11).'a' ); # LOC, no $2 needed
432
    $authmarc->field('008')->update( (' 'x11).'a' ); # LOC, no $2 needed
432
    AddAuthority( $authmarc, $id, $authtype1 ); # modify
433
    AddAuthority( $authmarc, $id, $authtype1 ); # modify
433
    merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
434
    merge({ mergefrom => $id, MARCfrom => $authmarc, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] });
434
    $biblio2 = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
435
    $biblio2 = Koha::Biblios->find($biblionumber)->metadata->record;
435
    is( $biblio2->subfield('609', '2'), undef, 'No subfield $2 left' );
436
    is( $biblio2->subfield('609', '2'), undef, 'No subfield $2 left' );
436
};
437
};
437
438
(-)a/tools/batch_delete_records.pl (-2 / +2 lines)
Lines 27-33 use Try::Tiny; Link Here
27
use C4::Auth qw( get_template_and_user );
27
use C4::Auth qw( get_template_and_user );
28
use C4::Output qw( output_html_with_http_headers );
28
use C4::Output qw( output_html_with_http_headers );
29
use C4::Auth qw( get_template_and_user );
29
use C4::Auth qw( get_template_and_user );
30
use C4::Biblio qw( GetMarcBiblio );
30
use C4::Biblio;
31
use C4::AuthoritiesMarc;
31
use C4::AuthoritiesMarc;
32
use Koha::Virtualshelves;
32
use Koha::Virtualshelves;
33
33
Lines 101-107 if ( $op eq 'form' ) { Link Here
101
                next;
101
                next;
102
            }
102
            }
103
            my $biblio = $biblio_object->unblessed;
103
            my $biblio = $biblio_object->unblessed;
104
            my $record = &GetMarcBiblio({ biblionumber => $record_id });
104
            my $record = $biblio_object->metadata->record;
105
            $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')];
105
            $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')];
106
            $biblio->{holds_count} = $biblio_object->holds->count;
106
            $biblio->{holds_count} = $biblio_object->holds->count;
107
            $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id );
107
            $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id );
(-)a/virtualshelves/shelves.pl (-4 / +2 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
21
use CGI qw ( -utf8 );
22
use C4::Auth qw( get_template_and_user );
22
use C4::Auth qw( get_template_and_user );
23
use C4::Biblio qw( GetMarcBiblio );
24
use C4::Koha qw(
23
use C4::Koha qw(
25
    GetNormalizedEAN
24
    GetNormalizedEAN
26
    GetNormalizedISBN
25
    GetNormalizedISBN
Lines 265-271 if ( $op eq 'view' ) { Link Here
265
            while ( my $content = $contents->next ) {
264
            while ( my $content = $contents->next ) {
266
                my $this_item;
265
                my $this_item;
267
                my $biblionumber = $content->biblionumber;
266
                my $biblionumber = $content->biblionumber;
268
                my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
267
                my $biblio       = Koha::Biblios->find($biblionumber);
268
                my $record       = $biblio->metadata->record;
269
269
270
                $this_item->{XSLTBloc} = XSLTParse4Display(
270
                $this_item->{XSLTBloc} = XSLTParse4Display(
271
                    {
271
                    {
Lines 279-285 if ( $op eq 'view' ) { Link Here
279
                my $marcflavour = C4::Context->preference("marcflavour");
279
                my $marcflavour = C4::Context->preference("marcflavour");
280
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
280
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
281
                $itemtype = Koha::ItemTypes->find( $itemtype );
281
                $itemtype = Koha::ItemTypes->find( $itemtype );
282
                my $biblio = Koha::Biblios->find( $content->biblionumber );
283
                $this_item->{title}             = $biblio->title;
282
                $this_item->{title}             = $biblio->title;
284
                $this_item->{subtitle}          = $biblio->subtitle;
283
                $this_item->{subtitle}          = $biblio->subtitle;
285
                $this_item->{medium}            = $biblio->medium;
284
                $this_item->{medium}            = $biblio->medium;
286
- 

Return to bug 29697