Applying patch from Daniel Feinberg for Containable

Removes __backContainableAssociation as its not needed and causes
more problems than it solves.
Fixes #1762
This commit is contained in:
mark_story 2011-09-07 20:39:12 -04:00
parent 95b275dc3b
commit ac0b2b8280

View file

@ -147,8 +147,6 @@ class ContainableBehavior extends ModelBehavior {
if (!empty($unbind)) {
if (!$reset && empty($instance->__backOriginalAssociation)) {
$instance->__backOriginalAssociation = $backupBindings;
} else if ($reset && empty($instance->__backContainableAssociation)) {
$instance->__backContainableAssociation = $backupBindings;
}
$instance->unbindModel(array($type => $unbind), $reset);
}
@ -219,24 +217,6 @@ class ContainableBehavior extends ModelBehavior {
return $query;
}
/**
* Resets original associations on models that may have receive multiple,
* subsequent unbindings.
*
* @param object $Model Model on which we are resetting
* @param array $results Results of the find operation
* @param bool $primary true if this is the primary model that issued the find operation, false otherwise
* @access public
*/
function afterFind(&$Model, $results, $primary) {
if (!empty($Model->__backContainableAssociation)) {
foreach ($Model->__backContainableAssociation as $relation => $bindings) {
$Model->{$relation} = $bindings;
unset($Model->__backContainableAssociation);
}
}
}
/**
* Unbinds all relations from a model except the specified ones. Calling this function without
* parameters unbinds all related models.