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

(-)a/C4/Biblio.pm (-10 / +4 lines)
Lines 226-232 sub AddBiblio { Link Here
226
    _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
226
    _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
227
227
228
    # now add the record
228
    # now add the record
229
    ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save;
229
    ModBiblioMarc( $record, $biblionumber ) unless $defer_marc_save;
230
230
231
    # update OAI-PMH sets
231
    # update OAI-PMH sets
232
    if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
232
    if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
Lines 314-320 sub ModBiblio { Link Here
314
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
314
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
315
315
316
    # update the MARC record (that now contains biblio and items) with the new record data
316
    # update the MARC record (that now contains biblio and items) with the new record data
317
    &ModBiblioMarc( $record, $biblionumber, $frameworkcode );
317
    &ModBiblioMarc( $record, $biblionumber );
318
318
319
    # modify the other koha tables
319
    # modify the other koha tables
320
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
320
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
Lines 3116-3122 sub _koha_delete_biblio_metadata { Link Here
3116
3116
3117
=head2 ModBiblioMarc
3117
=head2 ModBiblioMarc
3118
3118
3119
  &ModBiblioMarc($newrec,$biblionumber,$frameworkcode);
3119
  &ModBiblioMarc($newrec,$biblionumber);
3120
3120
3121
Add MARC XML data for a biblio to koha
3121
Add MARC XML data for a biblio to koha
3122
3122
Lines 3127-3133 Function exported, but should NOT be used, unless you really know what you're do Link Here
3127
sub ModBiblioMarc {
3127
sub ModBiblioMarc {
3128
    # pass the MARC::Record to this function, and it will create the records in
3128
    # pass the MARC::Record to this function, and it will create the records in
3129
    # the marcxml field
3129
    # the marcxml field
3130
    my ( $record, $biblionumber, $frameworkcode ) = @_;
3130
    my ( $record, $biblionumber ) = @_;
3131
    if ( !$record ) {
3131
    if ( !$record ) {
3132
        carp 'ModBiblioMarc passed an undefined record';
3132
        carp 'ModBiblioMarc passed an undefined record';
3133
        return;
3133
        return;
Lines 3137-3148 sub ModBiblioMarc { Link Here
3137
    $record = $record->clone();
3137
    $record = $record->clone();
3138
    my $dbh    = C4::Context->dbh;
3138
    my $dbh    = C4::Context->dbh;
3139
    my @fields = $record->fields();
3139
    my @fields = $record->fields();
3140
    if ( !$frameworkcode ) {
3141
        $frameworkcode = "";
3142
    }
3143
    my $sth = $dbh->prepare("UPDATE biblio SET frameworkcode=? WHERE biblionumber=?");
3144
    $sth->execute( $frameworkcode, $biblionumber );
3145
    $sth->finish;
3146
    my $encoding = C4::Context->preference("marcflavour");
3140
    my $encoding = C4::Context->preference("marcflavour");
3147
3141
3148
    # deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode
3142
    # deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode
(-)a/C4/Items.pm (-3 lines)
Lines 276-284 sub AddItemBatchFromMarc { Link Here
276
        $record->delete_field($item_field);
276
        $record->delete_field($item_field);
277
    }
277
    }
278
278
279
    # update the MARC biblio
280
 #   $biblionumber = ModBiblioMarc( $record, $biblionumber, $frameworkcode );
281
282
    return (\@itemnumbers, \@errors);
279
    return (\@itemnumbers, \@errors);
283
}
280
}
284
281
(-)a/misc/batchRepairMissingBiblionumbers.pl (-1 / +1 lines)
Lines 26-32 $sth->execute(); Link Here
26
while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){
26
while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){
27
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
27
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
28
    C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
28
    C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
29
    my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber, $frameworkcode )};
29
    my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber )};
30
    if($@){
30
    if($@){
31
        print "Problem with biblionumber : $biblionumber\n";
31
        print "Problem with biblionumber : $biblionumber\n";
32
        exit -1;
32
        exit -1;
(-)a/misc/migration_tools/22_to_30/missing090field.pl (-1 / +1 lines)
Lines 73-79 sub MARCmodbiblionumber{ Link Here
73
73
74
74
75
    if ($update){
75
    if ($update){
76
        &ModBiblioMarc($record,$biblionumber,'');
76
        &ModBiblioMarc($record,$biblionumber);
77
        print "\n modified : $biblionumber \n";
77
        print "\n modified : $biblionumber \n";
78
    }
78
    }
79
    
79
    
(-)a/misc/migration_tools/22_to_30/rebuild_leader.pl (-1 / +1 lines)
Lines 49-55 foreach ($record->field('995')) { Link Here
49
	$record->delete_field($_);
49
	$record->delete_field($_);
50
}
50
}
51
if ($update){	
51
if ($update){	
52
	&ModBiblioMarc($record,'',$biblionumber);
52
	&ModBiblioMarc($record,$biblionumber);
53
	print "$biblionumber \n";	
53
	print "$biblionumber \n";	
54
}
54
}
55
55
(-)a/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl (-1 / +1 lines)
Lines 56-62 sub MARCmodrecord { Link Here
56
            $record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>"$string"));
56
            $record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>"$string"));
57
        }
57
        }
58
    if ($update){
58
    if ($update){
59
        &ModBiblioMarc($record,$biblionumber,'');
59
        &ModBiblioMarc($record,$biblionumber);
60
        print "\r$biblionumber" unless ( $biblionumber % 100 );
60
        print "\r$biblionumber" unless ( $biblionumber % 100 );
61
    }
61
    }
62
62
(-)a/misc/migration_tools/bulkmarcimport.pl (-3 / +3 lines)
Lines 454-460 RECORD: while ( ) { Link Here
454
                    $biblioitemnumber = Koha::Biblios->find( $biblionumber )->biblioitem->biblioitemnumber;
454
                    $biblioitemnumber = Koha::Biblios->find( $biblionumber )->biblioitem->biblioitemnumber;
455
                };
455
                };
456
                if ($update) {
456
                if ($update) {
457
                    eval { ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber) ) };
457
                    eval { ModBiblio( $record, $biblionumber, $framework ) };
458
                    if ($@) {
458
                    if ($@) {
459
                        warn "ERROR: Edit biblio $biblionumber failed: $@\n";
459
                        warn "ERROR: Edit biblio $biblionumber failed: $@\n";
460
                        printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile);
460
                        printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile);
Lines 467-473 RECORD: while ( ) { Link Here
467
                }
467
                }
468
            } else {
468
            } else {
469
                if ($insert) {
469
                if ($insert) {
470
                    eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '', { defer_marc_save => 1 } ) };
470
                    eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, $framework, { defer_marc_save => 1 } ) };
471
                    if ($@) {
471
                    if ($@) {
472
                        warn "ERROR: Adding biblio $biblionumber failed: $@\n";
472
                        warn "ERROR: Adding biblio $biblionumber failed: $@\n";
473
                        printlog( { id => $id || $originalid || $biblionumber, op => "insert", status => "ERROR" } ) if ($logfile);
473
                        printlog( { id => $id || $originalid || $biblionumber, op => "insert", status => "ERROR" } ) if ($logfile);
Lines 489-495 RECORD: while ( ) { Link Here
489
            C4::Biblio::_strip_item_fields($clone_record, '');
489
            C4::Biblio::_strip_item_fields($clone_record, '');
490
            # This sets the marc fields if there was an error, and also calls
490
            # This sets the marc fields if there was an error, and also calls
491
            # defer_marc_save.
491
            # defer_marc_save.
492
            ModBiblioMarc( $clone_record, $biblionumber, $framework );
492
            ModBiblioMarc( $clone_record, $biblionumber );
493
            if ( $error_adding ) {
493
            if ( $error_adding ) {
494
                warn "ERROR: Adding items to bib $biblionumber failed: $error_adding";
494
                warn "ERROR: Adding items to bib $biblionumber failed: $error_adding";
495
				printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile);
495
				printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile);
(-)a/misc/migration_tools/switch_marc21_series_info.pl (-1 / +1 lines)
Lines 222-228 while ( my ( $biblionumber ) = $bibs_sth->fetchrow ) { Link Here
222
    else {
222
    else {
223
        print ".";
223
        print ".";
224
    }
224
    }
225
    ModBiblioMarc( $biblio, $biblionumber, $framework );
225
    ModBiblioMarc( $biblio, $biblionumber );
226
}
226
}
227
print "\n";
227
print "\n";
228
228
(-)a/t/db_dependent/Biblio/ModBiblioMarc.t (-2 / +1 lines)
Lines 40-46 subtest "Check MARC field length calculation" => sub { Link Here
40
    );
40
    );
41
41
42
    is( $record->leader, ' 'x24, 'No leader lengths' );
42
    is( $record->leader, ' 'x24, 'No leader lengths' );
43
    C4::Biblio::ModBiblioMarc( $record, $biblio->{biblionumber}, '' );
43
    C4::Biblio::ModBiblioMarc( $record, $biblio->{biblionumber} );
44
    my $savedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->{biblionumber} });
44
    my $savedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->{biblionumber} });
45
    like( substr($savedrec->leader,0,5), qr/^\d{5}$/, 'Record length found' );
45
    like( substr($savedrec->leader,0,5), qr/^\d{5}$/, 'Record length found' );
46
    like( substr($savedrec->leader,12,5), qr/^\d{5}$/, 'Base address found' );
46
    like( substr($savedrec->leader,12,5), qr/^\d{5}$/, 'Base address found' );
47
- 

Return to bug 25306