Set::combine() now returns an empty array if first passed var is empty. Fixes #4709 and #3784

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7002 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
joelmoss 2008-05-22 08:21:08 +00:00
parent fbdb4af2c1
commit 9b514352dc
2 changed files with 9 additions and 1 deletions

View file

@ -922,12 +922,15 @@ class Set extends Object {
* @access public
*/
function combine($data, $path1 = null, $path2 = null, $groupPath = null) {
if (empty($data)) {
return array();
}
if (is_a($this, 'set') && is_string($data) && is_string($path1) && is_string($path2)) {
$groupPath = $path2;
$path2 = $path1;
$path1 = $data;
$data = $this->get();
} elseif (is_a($this, 'set') && is_string($data) && empty($path2)) {
$path2 = $path1;
$path1 = $data;

View file

@ -727,6 +727,11 @@ class SetTest extends UnitTestCase {
}
function testCombine() {
$result = Set::combine(array(), '{n}.User.id', '{n}.User.Data');
$this->assertFalse($result);
$result = Set::combine('', '{n}.User.id', '{n}.User.Data');
$this->assertFalse($result);
$a = array(
array('User' => array('id' => 2, 'group_id' => 1,
'Data' => array('user' => 'mariano.iglesias','name' => 'Mariano Iglesias'))),