Permalink
Browse files

Another fix for array_values() throwing a warning when using Tree Be…

…havior under certain

situations.
  • Loading branch information...
1 parent 4b269e3 commit 2c1e6de7d628f38904f79ad631d5378254399305 @jperras jperras committed Feb 5, 2010
Showing with 7 additions and 2 deletions.
  1. +7 −2 cake/libs/model/behaviors/tree.php
@@ -163,10 +163,15 @@ function beforeSave(&$Model) {
$Model->data[$Model->alias][$parent] = null;
$this->_addToWhitelist($Model, $parent);
} else {
- list($node) = array_values($Model->find('first', array(
+ $values = $Model->find('first', array(
'conditions' => array($scope,$Model->escapeField() => $Model->id),
'fields' => array($Model->primaryKey, $parent, $left, $right ), 'recursive' => $recursive)
- ));
+ );
+
+ if ($values === false) {
+ return false;
+ }
+ list($node) = array_values($values);
$parentNode = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]),

0 comments on commit 2c1e6de

Please sign in to comment.