Bug 15451: Do not considered a Resultset as a Result
[koha.git] / Koha / Exporter / Record.pm
index b043411..ef2a37d 100644 (file)
@@ -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 );
     }