Skip to content

Commit

Permalink
Fix array_values() warning when using Tree Behavior under certain
Browse files Browse the repository at this point in the history
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 205c95e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cake/libs/model/behaviors/tree.php
Expand Up @@ -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;
Expand Down

0 comments on commit 205c95e

Please sign in to comment.