From bb584627248cc95443ebda511fca51effea6d0af Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 7 Mar 2013 13:03:27 +0100 Subject: [PATCH] [ticket/11404] Use a default data row if $row is empty in clean_row() A statically defined $default_row will be used inside the phpbb_avatar_manager::clean_row() method if the $row passed to it is empty. PHPBB3-11404 --- phpBB/includes/avatar/manager.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index f126d69300..58d994c3c0 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -45,6 +45,17 @@ class phpbb_avatar_manager */ protected $container; + /** + * Default avatar data row + * @var array + */ + static protected $default_row = array( + 'avatar' => '', + 'avatar_type' => '', + 'avatar_width' => '', + 'avatar_height' => '', + ); + /** * Construct an avatar manager object * @@ -174,20 +185,15 @@ class phpbb_avatar_manager */ static public function clean_row($row) { + // Upon creation of a user/group $row might be empty + if (empty($row)) + { + return self::$default_row; + } + $keys = array_keys($row); $values = array_values($row); - // Upon creation of a user/group $row might be empty - if (empty($keys)) - { - return array( - 'avatar' => '', - 'avatar_type' => '', - 'avatar_width' => '', - 'avatar_height' => '', - ); - } - $keys = array_map(array('phpbb_avatar_manager', 'strip_prefix'), $keys); return array_combine($keys, $values);