mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixed TreeBehavior::childCount(). Closes #1833
This commit is contained in:
parent
eaa01634b1
commit
9577fb0ca2
2 changed files with 6 additions and 1 deletions
|
@ -219,7 +219,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
|
||||
if ($id === null) {
|
||||
return $Model->find('count', array('conditions' => $scope));
|
||||
} elseif (isset($Model->data[$Model->alias][$left]) && isset($Model->data[$Model->alias][$right])) {
|
||||
} elseif ($Model->id === $id && isset($Model->data[$Model->alias][$left]) && isset($Model->data[$Model->alias][$right])) {
|
||||
$data = $Model->data[$Model->alias];
|
||||
} else {
|
||||
$data = $Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $id), 'recursive' => $recursive));
|
||||
|
|
|
@ -1118,6 +1118,11 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
|||
|
||||
$total = $this->Tree->childCount();
|
||||
$this->assertEqual($total, 6);
|
||||
|
||||
$this->Tree->read(null, $data[$modelClass]['id']);
|
||||
$id = $this->Tree->field('id', array($modelClass . '.name' => '1.2'));
|
||||
$total = $this->Tree->childCount($id);
|
||||
$this->assertEqual($total, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue