diff --git a/importexport/inc/class.importexport_basic_import_csv.inc.php b/importexport/inc/class.importexport_basic_import_csv.inc.php index 05f83cdc55..7c9e93d502 100644 --- a/importexport/inc/class.importexport_basic_import_csv.inc.php +++ b/importexport/inc/class.importexport_basic_import_csv.inc.php @@ -87,6 +87,11 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor */ protected $user = null; + /** + * Maximum number of errors or warnings before aborting + */ + const MAX_MESSAGES = 100; + /** * List of import errors */ @@ -157,7 +162,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor $warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']); - if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; + if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; $egw_record = new $record_class(); $egw_record->set_record($record); @@ -170,6 +175,11 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor { $this->preview_records[] = $egw_record; } + if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES) + { + $this->errors[] = 'Too many errors, aborted'; + break; + } } return $count; } @@ -298,12 +308,14 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor // Set up HTML $rows['h1'] = $labels; + error_log("Wow, ".count($this->preview_records) . ' preveiw records'); foreach($this->preview_records as $i => $row_data) { // Convert to human-friendly importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups); $rows[] = $row_data->get_record_array(); } + $this->preview_records = array(); return html::table($rows); }