From 6b4afb989e4257d47e022377297c0e453d49ddec Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 19 Nov 2012 14:03:03 -0500 Subject: [PATCH] Fix Set::merge() failing to merge correctly. When merging 3 values, and the 2nd was empty, the resulting merge was incorrect. Fixes #3384 --- lib/Cake/Test/Case/Utility/SetTest.php | 3 +++ lib/Cake/Utility/Set.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/SetTest.php b/lib/Cake/Test/Case/Utility/SetTest.php index c49ec3278..a8ccfef3e 100644 --- a/lib/Cake/Test/Case/Utility/SetTest.php +++ b/lib/Cake/Test/Case/Utility/SetTest.php @@ -152,6 +152,9 @@ class SetTest extends CakeTestCase { $r = Set::merge('foo', 'bar'); $this->assertEquals(array('foo', 'bar'), $r); + $r = Set::merge(array('foo'), array(), array('bar')); + $this->assertEquals(array('foo', 'bar'), $r); + $r = Set::merge('foo', array('user' => 'bob', 'no-bar'), 'bar'); $this->assertEquals(array('foo', 'user' => 'bob', 'no-bar', 'bar'), $r); diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 7ac63cfbe..f80dde8ea 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -45,7 +45,7 @@ class Set { */ public static function merge($data, $merge = null) { $args = func_get_args(); - if (empty($args[1])) { + if (empty($args[1]) && count($args) <= 2) { return (array)$args[0]; } if (!is_array($args[0])) {