Skip to content
Permalink
Browse files

Fix array_values() warning when using Tree Behavior under certain

situations.

In TreeBehavior::_setParent(), if the $Model->find('first') returned
false, then array_values() would throw a warning.
  • Loading branch information...
jperras committed Feb 2, 2010
1 parent 8d382d9 commit 205c95ef65e3a41cfef6ab11ffa1fa044e967470
Showing with 7 additions and 2 deletions.
  1. +7 −2 cake/libs/model/behaviors/tree.php
@@ -808,11 +808,16 @@ function _setParent(&$Model, $parentId = null, $created = false) {
$this->__sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
$this->__sync($Model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created);
} else {
$parentNode = array_values($Model->find('first', array(
$values = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $parentId),
'fields' => array($Model->primaryKey, $left, $right),
'recursive' => $recursive
)));
));
if ($values === false) {
return false;
}
$parentNode = array_values($values);
if (empty($parentNode) || empty($parentNode[0])) {
return false;

0 comments on commit 205c95e

Please sign in to comment.
You can’t perform that action at this time.