Merge pull request #516 from dogmatic69/tree-behavior-optimization

Tree behavior optimization

Fixes #2600
This commit is contained in:
Mark Story 2012-02-23 09:27:41 -08:00
commit 94db313e39

View file

@ -117,8 +117,10 @@ class TreeBehavior extends ModelBehavior {
*/
public function beforeDelete($Model, $cascade = true) {
extract($this->settings[$Model->alias]);
list($name, $data) = array($Model->alias, $Model->read());
$data = $data[$name];
$data = current($Model->find('first', array(
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
'fields' => array($Model->alias . '.' . $left, $Model->alias . '.' . $right),
'recursive' => -1)));
if (!$data[$right] || !$data[$left]) {
return true;