use C4::Biblio;
use C4::Record;
use Koha::CsvProfiles;
+use Koha::Logger;
sub _get_record_for_export {
my ($params) = @_;
} elsif ( $record_type eq 'bibs' ) {
$record = _get_biblio_for_export( { %$params, biblionumber => $record_id } );
} else {
-
- # TODO log "record_type not supported"
- return;
+ Koha::Logger->get->warn( "Record_type $record_type not supported." );
}
-
return unless $record;
if ($dont_export_fields) {
my $csv_profile_id = $params->{csv_profile_id};
my $output_filepath = $params->{output_filepath};
- return unless $record_type;
+ if( !$record_type ) {
+ Koha::Logger->get->warn( "No record_type given." );
+ return;
+ }
return unless @$record_ids;
my $fh;
my $record = _get_record_for_export( { %$params, record_id => $record_id } );
my $errorcount_on_decode = eval { scalar( MARC::File::USMARC->decode( $record->as_usmarc )->warnings() ) };
if ( $errorcount_on_decode or $@ ) {
- warn $@ if $@;
- warn "record (number $record_id) is invalid and therefore not exported because its reopening generates warnings above";
+ my $msg = "Record $record_id could not be exported. " .
+ ( $@ // '' );
+ chomp $msg;
+ Koha::Logger->get->info( $msg );
next;
}
print $record->as_usmarc();
print "\n";
for my $record_id (@$record_ids) {
my $record = _get_record_for_export( { %$params, record_id => $record_id } );
- next unless $record;
+ if( !$record ) {
+ Koha::Logger->get->info( "Record $record_id could not be exported." );
+ next;
+ }
print MARC::File::XML::record($record);
print "\n";
}
use Modern::Perl;
-use Test::More tests => 3;
+use Test::More tests => 4;
use t::lib::TestBuilder;
use MARC::Record;
is( $title, $biblio_2_title, 'Export ISO2709: The title is correctly encoded' );
};
+subtest 'export without record_type' => sub {
+ plan tests => 1;
+
+ my $rv = Koha::Exporter::Record::export({
+ record_ids => [ $biblionumber_1, $biblionumber_2 ],
+ format => 'iso2709',
+ output_filepath => 'does_not_matter_here',
+ });
+ is( $rv, undef, 'export returns undef' );
+ #Depending on your logger config, you might have a warn in your logs
+};
+
$schema->storage->txn_rollback;
1;