@@ -, +, @@ --- Koha/Exporter/Record.pm | 7 ++++++- misc/export_records.pl | 5 +++-- tools/export.pl | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) --- a/Koha/Exporter/Record.pm +++ a/Koha/Exporter/Record.pm @@ -134,7 +134,12 @@ sub export { print MARC::File::XML::footer(); print "\n"; } elsif ( $format eq 'csv' ) { - $csv_profile_id ||= Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') })->export_format_id; + unless ( $csv_profile_id ) { + # FIXME export_format.profile should be a unique key + my $csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); + die "The ExportWithCsvProfile system preference is not defined or does not match a valid csv profile" unless $csv_profiles->count; + $csv_profile_id = $csv_profiles->next->export_format_id; + } print marc2csv( $record_ids, $csv_profile_id, $itemnumbers ); } --- a/misc/export_records.pl +++ a/misc/export_records.pl @@ -195,8 +195,9 @@ if ($deleted_barcodes) { } else { unless ( $csv_profile_id ) { - my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); - $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef; + # FIXME export_format.profile should be a unique key + my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); + $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef; } Koha::Exporter::Record::export( { record_type => $record_type, --- a/tools/export.pl +++ a/tools/export.pl @@ -192,8 +192,9 @@ if ( $op eq "export" ) { my $csv_profile_id = $query->param('csv_profile_id'); unless ( $csv_profile_id ) { - my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); - $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef; + # FIXME export_format.profile should be a unique key + my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); + $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef; } Koha::Exporter::Record::export( --