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

(-)a/Koha/Exporter/Record.pm (-18 / +12 lines)
Lines 242-269 sub export { Link Here
242
        }
242
        }
243
        if ( $format eq 'iso2709' ) {
243
        if ( $format eq 'iso2709' ) {
244
            my $encoding_validator = sub {
244
            my $encoding_validator = sub {
245
                my ($record_type) = @_;
245
                my ($record, $record_type) = @_;
246
                return sub {
246
                my $errorcount_on_decode = eval { scalar(MARC::File::USMARC->decode($record->as_usmarc)->warnings()) };
247
                    my ($record) = @_;
247
                if ($errorcount_on_decode || $@) {
248
                    my $errorcount_on_decode = eval { scalar(MARC::File::USMARC->decode($record->as_usmarc)->warnings()) };
248
                    my ($id_tag, $id_subfield) = GetMarcFromKohaField('biblio.biblionumber', '');
249
                    if ($errorcount_on_decode || $@) {
249
                    my $record_id = $record->subfield($id_tag, $id_subfield);
250
                        my ($id_tag, $id_subfield) = GetMarcFromKohaField('biblio.biblionumber', '');
250
                    my $msg = "$record_type $record_id could not be USMARC decoded/encoded. " . ($@ // '');
251
                        my $record_id = $record->subfield($id_tag, $id_subfield);
251
                    chomp $msg;
252
                        my $msg = "$record_type $record_id could not be USMARC decoded/encoded. " . ($@ // '');
252
                    Koha::Logger->get->warn($msg);
253
                        chomp $msg;
253
                    return 0;
254
                        Koha::Logger->get->warn($msg);
255
                        return 0;
256
                    }
257
                    return 1;
258
                }
254
                }
255
                return 1;
259
            };
256
            };
260
            my $validator = $encoding_validator->('Record');
257
            for my $record (grep { $encoding_validator->($_, 'Record') } @records) {
261
            for my $record (grep { $validator->($_) } @records) {
262
                print $record->as_usmarc();
258
                print $record->as_usmarc();
263
            }
259
            }
264
            if (@deleted_records) {
260
            if (@deleted_records) {
265
                $validator = $encoding_validator->('Deleted record');
261
                for my $deleted_record (grep { $encoding_validator->($_, 'Deleted record') } @deleted_records) {
266
                for my $deleted_record (grep { $validator->($_) } @deleted_records) {
267
                    print $deleted_record->as_usmarc();
262
                    print $deleted_record->as_usmarc();
268
                }
263
                }
269
            }
264
            }
270
- 

Return to bug 20551