From a22617874c69d7bf5fc5a758cc05445f59d72c2a Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 10 Jul 2015 17:13:09 +0200 Subject: [PATCH] Fixing #623: Arr::map doesn't work with multidimensional array and keys Arr::map didn't pass the $keys array on to itself when doing the recursive call. This resulted at $callbacks being run on every element in multidimensional arrays. --- classes/Kohana/Arr.php | 2 +- tests/kohana/ArrTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/classes/Kohana/Arr.php b/classes/Kohana/Arr.php index fec1c2fa9..9d906f2f9 100644 --- a/classes/Kohana/Arr.php +++ b/classes/Kohana/Arr.php @@ -393,7 +393,7 @@ public static function map($callbacks, $array, $keys = NULL) { if (is_array($val)) { - $array[$key] = Arr::map($callbacks, $array[$key]); + $array[$key] = Arr::map($callbacks, $array[$key], $keys); } elseif ( ! is_array($keys) OR in_array($key, $keys)) { diff --git a/tests/kohana/ArrTest.php b/tests/kohana/ArrTest.php index 12a85efe1..a20ec23b7 100644 --- a/tests/kohana/ArrTest.php +++ b/tests/kohana/ArrTest.php @@ -655,6 +655,22 @@ public function provider_map() 'bar' => 'foobar', ), ), + array( + 'strip_tags', + array( + array( + 'foo' => '

foobar

', + 'bar' => '

foobar

', + ), + ), + array('foo'), + array( + array( + 'foo' => 'foobar', + 'bar' => '

foobar

', + ), + ), + ), ); }