Skip to content

Commit

Permalink
optimization of tree behavior as per ticket #2600
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Feb 23, 2012
1 parent b730285 commit 74a84c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Cake/Model/Behavior/TreeBehavior.php
Expand Up @@ -117,8 +117,9 @@ public function beforeFind($Model, $query) {
*/
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))));

if (!$data[$right] || !$data[$left]) {
return true;
Expand Down

0 comments on commit 74a84c9

Please sign in to comment.