Skip to content

Commit

Permalink
Fix Set::merge() failing to merge correctly.
Browse files Browse the repository at this point in the history
When merging 3 values, and the 2nd was empty, the resulting
merge was incorrect.

Fixes #3384
  • Loading branch information
markstory committed Nov 19, 2012
1 parent 4ebe754 commit 6b4afb9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/Cake/Test/Case/Utility/SetTest.php
Expand Up @@ -152,6 +152,9 @@ public function testMerge() {
$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);

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Set.php
Expand Up @@ -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])) {
Expand Down

0 comments on commit 6b4afb9

Please sign in to comment.