mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Fixed TreeBehavior::childCount(). Closes #1833
This commit is contained in:
parent
7a9ac53adf
commit
762fcf2c42
2 changed files with 7 additions and 2 deletions
|
@ -226,7 +226,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));
|
||||
|
@ -717,7 +717,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
|
||||
$db =& ConnectionManager::getDataSource($Model->useDbConfig);
|
||||
$Model->updateAll(
|
||||
array($parent => $db->value($node[$parent], $parent)),
|
||||
array($parent => $db->value($node[$parent], $parent)),
|
||||
array($Model->escapeField($parent) => $node[$Model->primaryKey])
|
||||
);
|
||||
$this->__sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
|
||||
|
|
|
@ -1112,6 +1112,11 @@ class NumberTreeTest 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