aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/phpbb/avatar/manager.php32
-rw-r--r--tests/avatar/manager_test.php50
2 files changed, 22 insertions, 60 deletions
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php
index 9f6a5fb089..12d7861cdf 100644
--- a/phpBB/phpbb/avatar/manager.php
+++ b/phpBB/phpbb/avatar/manager.php
@@ -195,33 +195,19 @@ class manager
return self::$default_row;
}
- $keys = array_keys($row);
- $values = array_values($row);
-
- array_walk($keys, array('\phpbb\avatar\manager', 'strip_prefix'), $prefix);
- $row = array_combine($keys, $values);
-
- if ($prefix == 'group')
+ $output = array();
+ foreach ($row as $key => $value)
{
- $row['id'] = 'g' . $row['id'];
+ $key = preg_replace("#^(?:{$prefix}_)#", '', $key);
+ $output[$key] = $value;
}
- return $row;
- }
+ if ($prefix === 'group' && isset($output['id']))
+ {
+ $output['id'] = 'g' . $output['id'];
+ }
- /**
- * Strip prepending user_ or group_ prefix from key
- *
- * @param string $key Array key
- * @param string $null Parameter is ignored by the function, just required by the array_walk
- * @param string $prefix Prefix that should be stripped off from the keys (e.g. user)
- * Should not include the trailing underscore
- * @return null
- */
- static protected function strip_prefix(&$key, $null, $prefix)
- {
- $regex = ($prefix !== '') ? "#^(?:{$prefix}_)#" : '#^(?:user_|group_)#';
- $key = preg_replace($regex, '', $key);
+ return $output;
}
/**
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index e9f622bfde..f29f7aee95 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -152,31 +152,20 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
return array(
array(
array(
- 'user_avatar' => '',
- 'user_avatar_type' => '',
- 'user_avatar_width' => '',
+ 'user_avatar' => '',
+ 'user_avatar_type' => '',
+ 'user_avatar_width' => '',
'user_avatar_height' => '',
+ 'group_avatar' => '',
),
array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => '',
- 'avatar_height' => '',
- ),
- ),
- array(
- array(
- 'group_avatar' => '',
- 'group_avatar_type' => '',
- 'group_avatar_width' => '',
- 'group_avatar_height' => '',
- ),
- array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => '',
- 'avatar_height' => '',
+ 'user_avatar' => '',
+ 'user_avatar_type' => '',
+ 'user_avatar_width' => '',
+ 'user_avatar_height' => '',
+ 'group_avatar' => '',
),
+ 'foobar',
),
array(
array(),
@@ -189,27 +178,14 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
),
array(
array(
- 'foobar_avatar' => '',
- 'foobar_avatar_type' => '',
- 'foobar_avatar_width' => '',
- 'foobar_avatar_height' => '',
- ),
- array(
- 'foobar_avatar' => '',
- 'foobar_avatar_type' => '',
- 'foobar_avatar_width' => '',
- 'foobar_avatar_height' => '',
- ),
- ),
- array(
- array(
'user_avatar' => '',
'user_id' => 5,
'group_id' => 4,
),
array(
- 'avatar' => '',
- 'id' => 4,
+ 'user_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
),
),
array(