X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FImportBatch.pm;h=63cc60b600c0a9b531f5d7a1f3a7e64d28a3a130;hb=f446b3d03d574e145bbc8f3e241ce2711c935643;hp=145e5d90a4b3bc9682f9923aa59083e5ab8aae77;hpb=ef8171ba425f766b67d9e139194b6a8d570e301e;p=koha_gimpoz diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 145e5d90a4..63cc60b600 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -210,7 +210,7 @@ sub ModBiblioInBatch { =head2 BatchStageMarcRecords ($batch_id, $num_records, $num_items, @invalid_records) = - BatchStageMarcRecords($marc_flavor, $marc_records, $file_name, + BatchStageMarcRecords($encoding, $marc_records, $file_name, $comments, $branch_code, $parse_items, $leave_as_staging, $progress_interval, $progress_callback); @@ -218,7 +218,7 @@ sub ModBiblioInBatch { =cut sub BatchStageMarcRecords { - my $marc_flavor = shift; + my $encoding = shift; my $marc_records = shift; my $file_name = shift; my $comments = shift; @@ -258,13 +258,16 @@ sub BatchStageMarcRecords { &$progress_callback($rec_num); } my ($marc_record, $charset_guessed, $char_errors) = - MarcToUTF8Record($marc_blob, C4::Context->preference("marcflavour")); + MarcToUTF8Record($marc_blob, C4::Context->preference("marcflavour"), $encoding); + + $encoding = $charset_guessed unless $encoding; + my $import_record_id; if (scalar($marc_record->fields()) == 0) { push @invalid_records, $marc_blob; } else { $num_valid++; - $import_record_id = AddBiblioToBatch($batch_id, $rec_num, $marc_record, $marc_flavor, int(rand(99999)), 0); + $import_record_id = AddBiblioToBatch($batch_id, $rec_num, $marc_record, $encoding, int(rand(99999)), 0); if ($parse_items) { my @import_items_ids = AddItemsToImportBiblio($batch_id, $import_record_id, $marc_record, 0); $num_items += scalar(@import_items_ids); @@ -1147,7 +1150,7 @@ sub _update_import_record_marc { my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ? WHERE import_record_id = ?"); - $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml(), $import_record_id); + $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml(C4::Context->preference('marcflavour')), $import_record_id); $sth->finish(); }