Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 205c95ef65e3a41cfef6ab11ffa1fa044e967470 1 parent 8d382d9
@jperras jperras authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 cake/libs/model/behaviors/tree.php
View
9 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;
Please sign in to comment.
Something went wrong with that request. Please try again.