Permalink
Browse files

Minor optimization in TreeBehavior::getparentnode() to avoid fetching…

… unneeded associated records. Closes #572
  • Loading branch information...
1 parent 404401b commit baaae6cdb79d368cf864777dd7133208d55f09c4 @ADmad ADmad committed Apr 12, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 cake/libs/model/behaviors/tree.php
View
2 cake/libs/model/behaviors/tree.php
@@ -382,7 +382,7 @@ function getparentnode(&$Model, $id = null, $fields = null, $recursive = null) {
if (!is_null($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) {
$parentId = $parentId[$Model->alias][$parent];

0 comments on commit baaae6c

Please sign in to comment.