From 2ff1107b78c1c998b6289f7a80a63d1268ac7c43 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 13 Jun 2014 16:03:16 +0000 Subject: [PATCH] Ignore favorite preferences which are not correctly serialized, and somehow are stroed in database. At the moment we just ignore them, but they stays in database, need to be watched closely to find the cause, though. --- etemplate/js/et2_widget_favorites.js | 2 +- phpgwapi/inc/class.egw_favorites.inc.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_widget_favorites.js b/etemplate/js/et2_widget_favorites.js index 831ca49b01..cab1ef362d 100644 --- a/etemplate/js/et2_widget_favorites.js +++ b/etemplate/js/et2_widget_favorites.js @@ -214,7 +214,7 @@ var et2_favorites = et2_dropdown_button.extend([et2_INextmatchHeader], var preferences = egw.preference("*",app); for(var pref_name in preferences) { - if(pref_name.indexOf(this.favorite_prefix) == 0) + if(pref_name.indexOf(this.favorite_prefix) == 0 && typeof preferences[pref_name] == 'object') { var name = pref_name.substr(this.favorite_prefix.length); stored_filters[name] = preferences[pref_name]; diff --git a/phpgwapi/inc/class.egw_favorites.inc.php b/phpgwapi/inc/class.egw_favorites.inc.php index 6ecbdc8c94..117d67d67c 100644 --- a/phpgwapi/inc/class.egw_favorites.inc.php +++ b/phpgwapi/inc/class.egw_favorites.inc.php @@ -34,7 +34,7 @@ class egw_favorites * a nextmatch is on the page, it will update / replace this list. * * @param string $app application, needed to find preferences - * @param string $default=null preference name for default favorite, default "nextmatch-$app.index.rows-favorite" + * @param string $default preference name for default favorite, default "nextmatch-$app.index.rows-favorite" * * @return array with a single sidebox menu item (array) containing html for favorites */ @@ -72,6 +72,13 @@ class egw_favorites } foreach($filters as $name => $filter) { + //filter must not be empty if there's one, ignore it at the moment but it need to be checked how it got there in database + if (!$filter) + { + error_log(__METHOD__.'Favorite filter is not suppose to be empty, it should be an array. filter = '. array2string($filters[$name])); + continue; + } + $href = "javascript:app.$app.setState(" . json_encode($filter,JSON_FORCE_OBJECT) . ');'; $li = "