diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index b9dfca72d..2351a5d6a 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1760,20 +1760,21 @@ class Model extends Overloadable { * * @param array $data Results of find operation * @param string $root NULL or id for root node of operation + * @param integer $index last processed index of $data * @return array Threaded results * @access private * @see Model::findAllThreaded() */ - function __doThread($data, $root) { + function __doThread($data, $root, $index = 0) { $out = array(); $sizeOf = sizeof($data); - for ($ii = 0; $ii < $sizeOf; $ii++) { + for ($ii = $index; $ii < $sizeOf; $ii++) { if (($data[$ii][$this->alias]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->alias]['parent_id'] == '0'))) { $tmp = $data[$ii]; if (isset($data[$ii][$this->alias][$this->primaryKey])) { - $tmp['children'] = $this->__doThread($data, $data[$ii][$this->alias][$this->primaryKey]); + $tmp['children'] = $this->__doThread($data, $data[$ii][$this->alias][$this->primaryKey], $ii); } else { $tmp['children'] = null; }