mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
cascade false for recover
This commit is contained in:
parent
22f65f7cb5
commit
354069d229
2 changed files with 22 additions and 13 deletions
|
@ -622,9 +622,9 @@ class TreeBehavior extends ModelBehavior {
|
|||
}
|
||||
return false;
|
||||
} elseif ($missingParentAction === 'delete') {
|
||||
$Model->deleteAll(array($Model->alias . '.' . $Model->primaryKey => array_flip($missingParents)));
|
||||
$Model->deleteAll(array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)), false);
|
||||
} else {
|
||||
$Model->updateAll(array($parent => $missingParentAction), array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)));
|
||||
$Model->updateAll(array($Model->escapeField($parent) => $missingParentAction), array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)));
|
||||
}
|
||||
}
|
||||
$count = 1;
|
||||
|
|
|
@ -183,19 +183,19 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
|||
$this->Tree = new $modelClass();
|
||||
$this->Tree->Behaviors->disable('Tree');
|
||||
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
||||
$node1 = $this->Tree->id;
|
||||
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$node11 = $this->Tree->id;
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$node12 = $this->Tree->id;
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
|
||||
|
||||
$this->Tree->Behaviors->enable('Tree');
|
||||
|
||||
|
@ -234,24 +234,33 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
|||
$this->Tree = new $modelClass();
|
||||
$this->Tree->Behaviors->disable('Tree');
|
||||
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
||||
$node1 = $this->Tree->id;
|
||||
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$node11 = $this->Tree->id;
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
|
||||
$node12 = $this->Tree->id;
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->create();
|
||||
$this->Tree->save(array('parent_id' => null, 'name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0));
|
||||
$this->Tree->save(array('name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0));
|
||||
|
||||
$this->Tree->Behaviors->enable('Tree');
|
||||
|
||||
$this->Tree->bindModel(array('belongsTo' => array('Parent' => array(
|
||||
'className' => $this->Tree->name,
|
||||
'foreignKey' => $parentField
|
||||
))));
|
||||
$this->Tree->bindModel(array('hasMany' => array('Child' => array(
|
||||
'className' => $this->Tree->name,
|
||||
'foreignKey' => $parentField
|
||||
))));
|
||||
|
||||
$result = $this->Tree->verify();
|
||||
$this->assertNotSame($result, true);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue