mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Found the bug and fixed it, closes #4693
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6977 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e1e71b6d93
commit
1224845967
2 changed files with 14 additions and 13 deletions
|
@ -265,10 +265,12 @@ class ContainableBehavior extends ModelBehavior {
|
|||
$children[$key] = (array)$val;
|
||||
}
|
||||
}
|
||||
|
||||
$keys = array_keys($children);
|
||||
if ($keys && isset($children[0])) {
|
||||
$keys = array_values($children);
|
||||
$keys = am(array_values($children), $keys);
|
||||
}
|
||||
|
||||
foreach ($keys as $i => $key) {
|
||||
if (is_array($key)) {
|
||||
continue;
|
||||
|
@ -291,7 +293,7 @@ class ContainableBehavior extends ModelBehavior {
|
|||
$key = $option;
|
||||
$optionKey = true;
|
||||
}
|
||||
if ($optionKey) {
|
||||
if ($optionKey && isset($children[$key])) {
|
||||
$keep[$name][$key] = array_merge((isset($keep[$name][$key]) ? $keep[$name][$key] : array()), (array) $children[$key]);
|
||||
unset($children[$key]);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,16 @@ class ContainableTest extends CakeTestCase {
|
|||
)
|
||||
)));
|
||||
$this->assertEqual(Set::extract('/ArticleFeatured/keep/Featured/fields', $r), array('id'));
|
||||
|
||||
$r = $this->__containments($this->Article, array(
|
||||
'Comment' => array(
|
||||
'User',
|
||||
'conditions' => array('Comment' => array('user_id' => 2)),
|
||||
),
|
||||
));
|
||||
$this->assertTrue(Set::matches('/User', $r));
|
||||
$this->assertTrue(Set::matches('/Comment', $r));
|
||||
$this->assertTrue(Set::matches('/Article/keep/Comment/conditions/Comment[user_id=2]', $r));
|
||||
}
|
||||
|
||||
function testInvalidContainments() {
|
||||
|
@ -172,17 +182,6 @@ class ContainableTest extends CakeTestCase {
|
|||
|
||||
$r = $this->Article->find('all');
|
||||
$this->assertFalse(Set::matches('/Comment/User', $r));
|
||||
|
||||
$this->Article->contain(array(
|
||||
'User',
|
||||
'Comment' => array(
|
||||
'conditions' => array('Comment' => array('user_id' => '!=2')),
|
||||
),
|
||||
'Tag'
|
||||
));
|
||||
$r = $this->Article->find('all');
|
||||
$this->assertFalse(Set::matches('/Comment[user_id=2]', $r));
|
||||
$this->assertTrue(Set::matches('/Comment[user_id!=2]', $r));
|
||||
}
|
||||
|
||||
function testFindEmbeddedNoBindings() {
|
||||
|
|
Loading…
Add table
Reference in a new issue