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

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

Return to bug 20551