From 6bbd7cff42d1a8738ca24374f117ba022574c4b9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 26 Oct 2013 18:42:39 +0200 Subject: [PATCH] [birthday/php_5_5_compat] Filter out array elements from lang dates --- root/portal/modules/portal_birthday_list.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/root/portal/modules/portal_birthday_list.php b/root/portal/modules/portal_birthday_list.php index b1378179..9567b855 100644 --- a/root/portal/modules/portal_birthday_list.php +++ b/root/portal/modules/portal_birthday_list.php @@ -172,8 +172,23 @@ class portal_birthday_list_module $date = explode('-', $birthday); $time = mktime(0, 0, 0, $date[1], $date[0], $date[2]); - $lang_dates = $user->lang['datetime']; + $lang_dates = array_filter($user->lang['datetime'], array($this, 'filter_lang_dates')); return strtr(date($date_settings, $time), $lang_dates); } + + /** + * Filter out lang dates that are not arrays. + * This is required in order to prevent PHP notices in PHP >= 5.4.12 + * that happen if an array that is passed to strtr() has rows that are + * arrays. + * + * @param mixed $row Current row of array + * + * @return bool True if array row is not an array + */ + protected function filter_lang_dates($row) + { + return !is_array($row); + } }