From 68798a2200fe29366ef294551449f0059c35d4af Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 14 Feb 2012 18:36:15 +0000 Subject: [PATCH] - Fix sorting by modification time to handle files changed at the same time - Catch exceptions for logging --- ...lass.importexport_basic_import_csv.inc.php | 1 + .../inc/class.importexport_import_csv.inc.php | 2 +- .../class.importexport_schedule_ui.inc.php | 20 +++++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/importexport/inc/class.importexport_basic_import_csv.inc.php b/importexport/inc/class.importexport_basic_import_csv.inc.php index b197a2c377..491ba9c5c3 100644 --- a/importexport/inc/class.importexport_basic_import_csv.inc.php +++ b/importexport/inc/class.importexport_basic_import_csv.inc.php @@ -131,6 +131,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor $this->results = array(); // Failures + $this->warnings = array(); $this->errors = array(); while ( $record = $import_csv->get_record() ) { diff --git a/importexport/inc/class.importexport_import_csv.inc.php b/importexport/inc/class.importexport_import_csv.inc.php index 0b99149026..99494a5628 100755 --- a/importexport/inc/class.importexport_import_csv.inc.php +++ b/importexport/inc/class.importexport_import_csv.inc.php @@ -372,7 +372,7 @@ class importexport_import_csv implements importexport_iface_import_record { //, // Need to handle format first if($format == 1) { - $formatted = egw_time::createFromFormat(egw_time::$user_dateformat, $record[$name]); + $formatted = egw_time::createFromFormat('!'.egw_time::$user_dateformat, $record[$name]); if($formatted && $errors = egw_time::getLastErrors() && $errors['error_count'] == 0) { $record[$name] = $formatted->getTimestamp(); diff --git a/importexport/inc/class.importexport_schedule_ui.inc.php b/importexport/inc/class.importexport_schedule_ui.inc.php index fc76eac944..ef294ce27f 100644 --- a/importexport/inc/class.importexport_schedule_ui.inc.php +++ b/importexport/inc/class.importexport_schedule_ui.inc.php @@ -422,7 +422,7 @@ unset($targets[$key]); continue; } - $files[$mod_time] = $target; + $files[$mod_time.$target] = $target; } if($files) { @@ -438,13 +438,21 @@ foreach($targets as $target) { - if($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' )) { - $result = $po->$type( $resource, $definition ); + $resource = null; + try { + if($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' )) { + $result = $po->$type( $resource, $definition ); + fclose($resource); + } else { + fwrite(STDERR,'importexport_schedule: ' . date('c') . ": File $target not readable! \n"); + $data['errors'][$target][] = lang('%1 is not readable',$target); + } + } + catch (Exception $i_ex) + { fclose($resource); - } else { - fwrite(STDERR,'importexport_schedule: ' . date('c') . ": File $target not readable! \n"); - $data['errors'][$target][] = lang('%1 is not readable',$target); + $data['errors'][$target][] = $i_ex->getMessage(); }