mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fixes #4790, restoring associations in Containable. Thanks to maular for the patch
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7245 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
9661a54a13
commit
ca38b035b5
2 changed files with 122 additions and 120 deletions
|
@ -134,6 +134,14 @@ class ContainableBehavior extends ModelBehavior {
|
|||
if (!isset($model['keep'][$assoc])) {
|
||||
$unbind[] = $assoc;
|
||||
}
|
||||
}
|
||||
if ($unbind) {
|
||||
if (!$reset && empty($instance->__backOriginalAssociation)) {
|
||||
$instance->__backOriginalAssociation = $backupBindings;
|
||||
}
|
||||
$instance->unbindModel(array($type => $unbind), $reset);
|
||||
}
|
||||
foreach ($instance->{$type} as $assoc => $options) {
|
||||
if (isset($model['keep'][$assoc]) && !empty($model['keep'][$assoc])) {
|
||||
if (isset($model['keep'][$assoc]['fields'])) {
|
||||
$model['keep'][$assoc]['fields'] = $this->fieldDependencies($containments['models'][$assoc]['instance'], $map, $model['keep'][$assoc]['fields']);
|
||||
|
@ -149,12 +157,6 @@ class ContainableBehavior extends ModelBehavior {
|
|||
$instance->__backInnerAssociation[] = $assoc;
|
||||
}
|
||||
}
|
||||
if ($unbind) {
|
||||
if (!$reset && empty($instance->__backOriginalAssociation)) {
|
||||
$instance->__backOriginalAssociation = $backupBindings;
|
||||
}
|
||||
$instance->unbindModel(array($type => $unbind), $reset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3204,7 +3204,7 @@ class ContainableTest extends CakeTestCase {
|
|||
|
||||
$options = array(
|
||||
'conditions' => array(
|
||||
'Comment.comment' => '!= Crazy',
|
||||
'Comment.comment !=' => 'Crazy',
|
||||
'Comment.published' => 'Y',
|
||||
),
|
||||
'contain' => 'User',
|
||||
|
@ -3215,7 +3215,7 @@ class ContainableTest extends CakeTestCase {
|
|||
|
||||
$dummyResult = $this->Article->Comment->find('all', array(
|
||||
'conditions' => array(
|
||||
'Comment.comment' => '!= Silly',
|
||||
'Comment.comment !=' => 'Silly',
|
||||
'User.user' => 'mariano'
|
||||
),
|
||||
'fields' => array('User.password'),
|
||||
|
|
Loading…
Reference in a new issue