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

(-)a/C4/ImportBatch.pm (-7 / +14 lines)
Lines 308-314 sub AddItemsToImportBiblio { Link Here
308
                                        VALUES (?, ?, ?)");
308
                                        VALUES (?, ?, ?)");
309
        $sth->bind_param(1, $import_record_id);
309
        $sth->bind_param(1, $import_record_id);
310
        $sth->bind_param(2, 'staged');
310
        $sth->bind_param(2, 'staged');
311
        $sth->bind_param(3, $item_marc->as_xml());
311
        $sth->bind_param(3, $item_marc->as_xml(C4::Context->preference('marcflavour')));
312
        $sth->execute();
312
        $sth->execute();
313
        push @import_items_ids, $dbh->{'mysql_insertid'};
313
        push @import_items_ids, $dbh->{'mysql_insertid'};
314
        $sth->finish();
314
        $sth->finish();
Lines 440-447 sub BatchCommitBibRecords { Link Here
440
            next;
440
            next;
441
        }
441
        }
442
442
443
        my $marc_record = MARC::Record->new_from_usmarc($rowref->{'marc'});
443
        my $marc_record = eval{MARC::Record->new_from_usmarc($rowref->{'marc'})};
444
444
445
	if ($@ or !defined $marc_record ){
446
	    next;
447
	}
445
        # remove any item tags - rely on BatchCommitItems
448
        # remove any item tags - rely on BatchCommitItems
446
        my ($item_tag,$item_subfield) = &GetMarcFromKohaField("items.itemnumber",'');
449
        my ($item_tag,$item_subfield) = &GetMarcFromKohaField("items.itemnumber",'');
447
        foreach my $item_field ($marc_record->field($item_tag)) {
450
        foreach my $item_field ($marc_record->field($item_tag)) {
Lines 455-461 sub BatchCommitBibRecords { Link Here
455
458
456
        if ($bib_result eq 'create_new') {
459
        if ($bib_result eq 'create_new') {
457
            $num_added++;
460
            $num_added++;
458
            my ($biblionumber, $biblioitemnumber) = AddBiblio($marc_record, $framework);
461
            my ($biblionumber, $biblioitemnumber) = eval{AddBiblio($marc_record, $framework)};
462
	    if ($@ or !defined $biblionumber){
463
	       $num_added--;
464
	       $num_ignored++;
465
	       next;
466
	    }
459
            my $sth = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?");
467
            my $sth = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?");
460
            $sth->execute($biblionumber, $rowref->{'import_record_id'});
468
            $sth->execute($biblionumber, $rowref->{'import_record_id'});
461
            $sth->finish();
469
            $sth->finish();
Lines 480-486 sub BatchCommitBibRecords { Link Here
480
488
481
            ModBiblio($marc_record, $biblionumber, $oldbiblio->{'frameworkcode'});
489
            ModBiblio($marc_record, $biblionumber, $oldbiblio->{'frameworkcode'});
482
            my $sth = $dbh->prepare_cached("UPDATE import_records SET marcxml_old = ? WHERE import_record_id = ?");
490
            my $sth = $dbh->prepare_cached("UPDATE import_records SET marcxml_old = ? WHERE import_record_id = ?");
483
            $sth->execute($old_marc->as_xml(), $rowref->{'import_record_id'});
491
            $sth->execute($old_marc->as_xml(C4::Context->preference('marcflavour')), $rowref->{'import_record_id'});
484
            $sth->finish();
492
            $sth->finish();
485
            my $sth2 = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?");
493
            my $sth2 = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?");
486
            $sth2->execute($biblionumber, $rowref->{'import_record_id'});
494
            $sth2->execute($biblionumber, $rowref->{'import_record_id'});
Lines 1137-1143 sub _create_import_record { Link Here
1137
    my $sth = $dbh->prepare("INSERT INTO import_records (import_batch_id, record_sequence, marc, marcxml, 
1145
    my $sth = $dbh->prepare("INSERT INTO import_records (import_batch_id, record_sequence, marc, marcxml, 
1138
                                                         record_type, encoding, z3950random)
1146
                                                         record_type, encoding, z3950random)
1139
                                    VALUES (?, ?, ?, ?, ?, ?, ?)");
1147
                                    VALUES (?, ?, ?, ?, ?, ?, ?)");
1140
    $sth->execute($batch_id, $record_sequence, $marc_record->as_usmarc(), $marc_record->as_xml(),
1148
    $sth->execute($batch_id, $record_sequence, $marc_record->as_usmarc(), $marc_record->as_xml(C4::Context->preference('marcflavour')),
1141
                  $record_type, $encoding, $z3950random);
1149
                  $record_type, $encoding, $z3950random);
1142
    my $import_record_id = $dbh->{'mysql_insertid'};
1150
    my $import_record_id = $dbh->{'mysql_insertid'};
1143
    $sth->finish();
1151
    $sth->finish();
Lines 1150-1156 sub _update_import_record_marc { Link Here
1150
    my $dbh = C4::Context->dbh;
1158
    my $dbh = C4::Context->dbh;
1151
    my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ?
1159
    my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ?
1152
                             WHERE  import_record_id = ?");
1160
                             WHERE  import_record_id = ?");
1153
    $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml(), $import_record_id);
1161
    $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml(C4::Context->preference('marcflavour')), $import_record_id);
1154
    $sth->finish();
1162
    $sth->finish();
1155
}
1163
}
1156
1164
1157
- 

Return to bug 7513