From fcd731a00b2cc2ce15585d25db120b80365f089a Mon Sep 17 00:00:00 2001 From: Christian Binder Date: Tue, 2 Mar 2010 18:01:41 +0000 Subject: [PATCH] prevent iterating on empty array --- calendar/inc/class.calendar_boupdate.inc.php | 29 +++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 95538d9aab..7cab1e2301 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1421,24 +1421,27 @@ class calendar_boupdate extends calendar_bo } $cat_id_list = array(); - foreach ($catname_list as $cat_name) + if(is_array($catname_list) && count($catname_list) > 0) { - $cat_name = trim($cat_name); - $cat_id = $this->categories->name2id($cat_name, 'X-'); - - if (!$cat_id) + foreach ($catname_list as $cat_name) { - // some SyncML clients (mostly phones) add an X- to the category names - if (strncmp($cat_name, 'X-', 2) == 0) + $cat_name = trim($cat_name); + $cat_id = $this->categories->name2id($cat_name, 'X-'); + + if (!$cat_id) { - $cat_name = substr($cat_name, 2); + // some SyncML clients (mostly phones) add an X- to the category names + if (strncmp($cat_name, 'X-', 2) == 0) + { + $cat_name = substr($cat_name, 2); + } + $cat_id = $this->categories->add(array('name' => $cat_name, 'descr' => $cat_name, 'access' => 'private')); } - $cat_id = $this->categories->add(array('name' => $cat_name, 'descr' => $cat_name, 'access' => 'private')); - } - if ($cat_id) - { - $cat_id_list[] = $cat_id; + if ($cat_id) + { + $cat_id_list[] = $cat_id; + } } }