Skip to content

Commit

Permalink
Another fix for array_values() throwing a warning when using Tree Be…
Browse files Browse the repository at this point in the history
…havior under certain

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

if ($values === false) {
return false;
}
list($node) = array_values($values);


$parentNode = $Model->find('first', array( $parentNode = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]),
Expand Down

0 comments on commit 2c1e6de

Please sign in to comment.