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

(-)a/C4/Biblio.pm (-10 / +4 lines)
Lines 285-291 sub AddBiblio { Link Here
285
            _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
285
            _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
286
286
287
            # now add the record
287
            # now add the record
288
            ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save;
288
            ModBiblioMarc( $record, $biblionumber ) unless $defer_marc_save;
289
289
290
            # update OAI-PMH sets
290
            # update OAI-PMH sets
291
            if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
291
            if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
Lines 378-384 sub ModBiblio { Link Here
378
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
378
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
379
379
380
    # update the MARC record (that now contains biblio and items) with the new record data
380
    # update the MARC record (that now contains biblio and items) with the new record data
381
    &ModBiblioMarc( $record, $biblionumber, $frameworkcode );
381
    &ModBiblioMarc( $record, $biblionumber );
382
382
383
    # modify the other koha tables
383
    # modify the other koha tables
384
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
384
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
Lines 2982-2988 sub _koha_delete_biblio_metadata { Link Here
2982
2982
2983
=head2 ModBiblioMarc
2983
=head2 ModBiblioMarc
2984
2984
2985
  &ModBiblioMarc($newrec,$biblionumber,$frameworkcode);
2985
  &ModBiblioMarc($newrec,$biblionumber);
2986
2986
2987
Add MARC XML data for a biblio to koha
2987
Add MARC XML data for a biblio to koha
2988
2988
Lines 2993-2999 Function exported, but should NOT be used, unless you really know what you're do Link Here
2993
sub ModBiblioMarc {
2993
sub ModBiblioMarc {
2994
    # pass the MARC::Record to this function, and it will create the records in
2994
    # pass the MARC::Record to this function, and it will create the records in
2995
    # the marcxml field
2995
    # the marcxml field
2996
    my ( $record, $biblionumber, $frameworkcode ) = @_;
2996
    my ( $record, $biblionumber ) = @_;
2997
    if ( !$record ) {
2997
    if ( !$record ) {
2998
        carp 'ModBiblioMarc passed an undefined record';
2998
        carp 'ModBiblioMarc passed an undefined record';
2999
        return;
2999
        return;
Lines 3003-3014 sub ModBiblioMarc { Link Here
3003
    $record = $record->clone();
3003
    $record = $record->clone();
3004
    my $dbh    = C4::Context->dbh;
3004
    my $dbh    = C4::Context->dbh;
3005
    my @fields = $record->fields();
3005
    my @fields = $record->fields();
3006
    if ( !$frameworkcode ) {
3007
        $frameworkcode = "";
3008
    }
3009
    my $sth = $dbh->prepare("UPDATE biblio SET frameworkcode=? WHERE biblionumber=?");
3010
    $sth->execute( $frameworkcode, $biblionumber );
3011
    $sth->finish;
3012
    my $encoding = C4::Context->preference("marcflavour");
3006
    my $encoding = C4::Context->preference("marcflavour");
3013
3007
3014
    # deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode
3008
    # 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 25-31 $sth->execute(); Link Here
25
while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){
25
while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){
26
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
26
    my $record = GetMarcBiblio({ biblionumber => $biblionumber });
27
    C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
27
    C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
28
    my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber, $frameworkcode )};
28
    my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber )};
29
    if($@){
29
    if($@){
30
        print "Problem with biblionumber : $biblionumber\n";
30
        print "Problem with biblionumber : $biblionumber\n";
31
        exit -1;
31
        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 444-450 RECORD: while ( ) { Link Here
444
                    $biblioitemnumber = Koha::Biblios->find( $biblionumber )->biblioitem->biblioitemnumber;
444
                    $biblioitemnumber = Koha::Biblios->find( $biblionumber )->biblioitem->biblioitemnumber;
445
                };
445
                };
446
                if ($update) {
446
                if ($update) {
447
                    eval { ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber) ) };
447
                    eval { ModBiblio( $record, $biblionumber, $framework ) };
448
                    if ($@) {
448
                    if ($@) {
449
                        warn "ERROR: Edit biblio $biblionumber failed: $@\n";
449
                        warn "ERROR: Edit biblio $biblionumber failed: $@\n";
450
                        printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile);
450
                        printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile);
Lines 457-463 RECORD: while ( ) { Link Here
457
                }
457
                }
458
            } else {
458
            } else {
459
                if ($insert) {
459
                if ($insert) {
460
                    eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '', { defer_marc_save => 1 } ) };
460
                    eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, $framework, { defer_marc_save => 1 } ) };
461
                    if ($@) {
461
                    if ($@) {
462
                        warn "ERROR: Adding biblio $biblionumber failed: $@\n";
462
                        warn "ERROR: Adding biblio $biblionumber failed: $@\n";
463
                        printlog( { id => $id || $originalid || $biblionumber, op => "insert", status => "ERROR" } ) if ($logfile);
463
                        printlog( { id => $id || $originalid || $biblionumber, op => "insert", status => "ERROR" } ) if ($logfile);
Lines 479-485 RECORD: while ( ) { Link Here
479
            C4::Biblio::_strip_item_fields($clone_record, '');
479
            C4::Biblio::_strip_item_fields($clone_record, '');
480
            # This sets the marc fields if there was an error, and also calls
480
            # This sets the marc fields if there was an error, and also calls
481
            # defer_marc_save.
481
            # defer_marc_save.
482
            ModBiblioMarc( $clone_record, $biblionumber, $framework );
482
            ModBiblioMarc( $clone_record, $biblionumber );
483
            if ( $error_adding ) {
483
            if ( $error_adding ) {
484
                warn "ERROR: Adding items to bib $biblionumber failed: $error_adding";
484
                warn "ERROR: Adding items to bib $biblionumber failed: $error_adding";
485
				printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile);
485
				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