mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Applied patch by floob, fixes #4876
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7234 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f7c447aa32
commit
95522fa3a9
2 changed files with 27 additions and 0 deletions
|
@ -769,6 +769,9 @@ class TreeBehavior extends ModelBehavior {
|
||||||
if (is_null($instance[$model->alias][$left]) || is_null($instance[$model->alias][$right])) {
|
if (is_null($instance[$model->alias][$left]) || is_null($instance[$model->alias][$right])) {
|
||||||
$errors[] = array('node', $instance[$model->alias][$model->primaryKey],
|
$errors[] = array('node', $instance[$model->alias][$model->primaryKey],
|
||||||
'has invalid left or right values');
|
'has invalid left or right values');
|
||||||
|
} elseif ($instance[$model->alias][$left] == $instance[$model->alias][$right]){
|
||||||
|
$errors[] = array('node', $instance[$model->alias][$model->primaryKey],
|
||||||
|
'left and right values identical');
|
||||||
} elseif ($instance[$model->alias][$parent]) {
|
} elseif ($instance[$model->alias][$parent]) {
|
||||||
if (!$instance['VerifyParent'][$model->primaryKey]) {
|
if (!$instance['VerifyParent'][$model->primaryKey]) {
|
||||||
$errors[] = array('node', $instance[$model->alias][$model->primaryKey],
|
$errors[] = array('node', $instance[$model->alias][$model->primaryKey],
|
||||||
|
|
|
@ -415,6 +415,30 @@ class NumberTreeCase extends CakeTestCase {
|
||||||
$result = $this->NumberTree->verify();
|
$result = $this->NumberTree->verify();
|
||||||
$this->assertIdentical($result, true);
|
$this->assertIdentical($result, true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Reproduces a situation where a single node has lft=rght, and all other lft and rght fields follow sequentially
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testDetectEqualLftsRghts() {
|
||||||
|
$this->NumberTree =& new NumberTree();
|
||||||
|
$this->NumberTree->initialize(1, 3);
|
||||||
|
|
||||||
|
$result = $this->NumberTree->findByName('1.1');
|
||||||
|
$this->NumberTree->updateAll(array('rght' => $result['NumberTree']['lft']), array('id' => $result['NumberTree']['id']));
|
||||||
|
$this->NumberTree->updateAll(array('lft' => 'lft-1'), array('lft >' => $result['NumberTree']['lft']));
|
||||||
|
$this->NumberTree->updateAll(array('rght' => 'rght-1'), array('rght >' => $result['NumberTree']['lft']));
|
||||||
|
|
||||||
|
$result = $this->NumberTree->verify();
|
||||||
|
$this->assertNotIdentical($result, true);
|
||||||
|
|
||||||
|
$result = $this->NumberTree->recover();
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
$result = $this->NumberTree->verify();
|
||||||
|
$this->assertTrue($result);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* testAddOrphan method
|
* testAddOrphan method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue