Fix issues with TreeBehavior and nested deletes.

Fixes #3481
This commit is contained in:
mark_story 2012-12-19 20:48:51 -05:00
parent 1612bdf250
commit d70730d722

View file

@ -52,7 +52,7 @@ class TreeBehavior extends ModelBehavior {
* *
* @var array * @var array
*/ */
protected $_deletedRow = null; protected $_deletedRow = array();
/** /**
* Initiate Tree behavior * Initiate Tree behavior
@ -129,7 +129,7 @@ class TreeBehavior extends ModelBehavior {
'fields' => array($Model->escapeField($left), $Model->escapeField($right)), 'fields' => array($Model->escapeField($left), $Model->escapeField($right)),
'recursive' => -1)); 'recursive' => -1));
if ($data) { if ($data) {
$this->_deletedRow = current($data); $this->_deletedRow[$Model->alias] = current($data);
} }
return true; return true;
} }
@ -144,8 +144,8 @@ class TreeBehavior extends ModelBehavior {
*/ */
public function afterDelete(Model $Model) { public function afterDelete(Model $Model) {
extract($this->settings[$Model->alias]); extract($this->settings[$Model->alias]);
$data = $this->_deletedRow; $data = $this->_deletedRow[$Model->alias];
$this->_deletedRow = null; $this->_deletedRow[$Model->alias] = null;
if (!$data[$right] || !$data[$left]) { if (!$data[$right] || !$data[$left]) {
return true; return true;