mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix Set::merge() failing to merge correctly.
When merging 3 values, and the 2nd was empty, the resulting merge was incorrect. Fixes #3384
This commit is contained in:
parent
4ebe754076
commit
6b4afb989e
2 changed files with 4 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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])) {
|
||||
|
|
Loading…
Reference in a new issue