mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
Abort import if more than 100 errors are encountered.
Prevents request from dying if you upload a large, bad, file
This commit is contained in:
parent
4053d1a204
commit
f5dc2d6903
@ -87,6 +87,11 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
|
|||||||
*/
|
*/
|
||||||
protected $user = null;
|
protected $user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of errors or warnings before aborting
|
||||||
|
*/
|
||||||
|
const MAX_MESSAGES = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of import errors
|
* 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']);
|
$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 = new $record_class();
|
||||||
$egw_record->set_record($record);
|
$egw_record->set_record($record);
|
||||||
@ -170,6 +175,11 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
|
|||||||
{
|
{
|
||||||
$this->preview_records[] = $egw_record;
|
$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;
|
return $count;
|
||||||
}
|
}
|
||||||
@ -298,12 +308,14 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
|
|||||||
|
|
||||||
// Set up HTML
|
// Set up HTML
|
||||||
$rows['h1'] = $labels;
|
$rows['h1'] = $labels;
|
||||||
|
error_log("Wow, ".count($this->preview_records) . ' preveiw records');
|
||||||
foreach($this->preview_records as $i => $row_data)
|
foreach($this->preview_records as $i => $row_data)
|
||||||
{
|
{
|
||||||
// Convert to human-friendly
|
// Convert to human-friendly
|
||||||
importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups);
|
importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups);
|
||||||
$rows[] = $row_data->get_record_array();
|
$rows[] = $row_data->get_record_array();
|
||||||
}
|
}
|
||||||
|
$this->preview_records = array();
|
||||||
|
|
||||||
return html::table($rows);
|
return html::table($rows);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user