Minor optimization in TreeBehavior::getparentnode() to avoid fetching unneeded associated records. Closes #572

This commit is contained in:
ADmad 2010-04-12 22:57:31 +05:30
parent 404401b4de
commit baaae6cdb7

View file

@ -382,7 +382,7 @@ class TreeBehavior extends ModelBehavior {
if (!is_null($overrideRecursive)) { if (!is_null($overrideRecursive)) {
$recursive = $overrideRecursive; $recursive = $overrideRecursive;
} }
$parentId = $Model->read($parent, $id); $parentId = $Model->find('first', array('conditions' => array($Model->primaryKey => $id), 'fields' => array($parent), 'recursive' => -1));
if ($parentId) { if ($parentId) {
$parentId = $parentId[$Model->alias][$parent]; $parentId = $parentId[$Model->alias][$parent];