From 9319cfd8c4daab0efd97b151be8860572b9f16c2 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 13 Mar 2012 10:23:59 +0000 Subject: [PATCH] trying to work arround "PHP Fatal error: Cannot unset string offsets in /usr/share/egroupware/importexport/inc/class.importexport_schedule_ui.inc.php on line 444" --- .../class.importexport_schedule_ui.inc.php | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/importexport/inc/class.importexport_schedule_ui.inc.php b/importexport/inc/class.importexport_schedule_ui.inc.php index 4c4032cc85..a0cafb6899 100644 --- a/importexport/inc/class.importexport_schedule_ui.inc.php +++ b/importexport/inc/class.importexport_schedule_ui.inc.php @@ -187,7 +187,7 @@ foreach($types[$data['type']] as $key => $title) { $options['plugin'][$key] = $title; } - } + } } $options['definition'] = array(); @@ -393,7 +393,7 @@ // Lock job for an hour to prevent multiples overlapping $data['lock'] = time() + 3600; self::update_job($data, true); - + // check file $file_check = self::check_target($data); if($file_check !== true) { @@ -423,35 +423,26 @@ if(is_dir($data['target'])) { - $dir = opendir($data['target']); - $contents = array(); - while(false !== ($item = readdir($dir))) { - $contents[] = $item; - } - closedir($dir); - $targets = array_diff($contents, array('.','..')); - $files = array(); - foreach($targets as $key => &$target) + $targets = array(); + foreach(scandir($data['target']) as $target) { + if ($target == '.' || $target == '..') continue; $target = $data['target'].(substr($data['target'],-1) == '/' ? '' : '/').$target; - + // Check modification time, make sure it's not currently being written // Skip files modified in the last 10 seconds $mod_time = filemtime($target); - if($mod_time >= time() - 10) + if($mod_time >= time() - 10) { $data['result'][$target] = lang('Skipped'); - unset($target[$key]); continue; } - $files[$mod_time.$target] = $target; + $targets[$mod_time.$target] = $target; } - if($files) + if($targets) { - ksort($files); + ksort($targets); } - $targets = $files; - unset($target); // Unset it, or it will be overwritten in loop below } else { @@ -480,7 +471,7 @@ fclose($resource); $data['errors'][$target][] = $i_ex->getMessage(); } - + if(method_exists($po, 'get_warnings') && $po->get_warnings()) { fwrite(STDERR, 'importexport_schedule: ' . date('c') . ": Import warnings:\n#\tWarning\n");