Skip to content
Permalink
Browse files

Fixed issue Multi-Tree Deleting Nodes outside the Scope

GitHub Issue #11289
  • Loading branch information...
jonmc1 committed Oct 9, 2017
1 parent 4fabcc8 commit 66bfde9e8877994f182be2a0ecbb9b1885b47278
Showing with 10 additions and 6 deletions.
  1. +10 −6 src/ORM/Behavior/TreeBehavior.php
@@ -224,12 +224,16 @@ public function beforeDelete(Event $event, EntityInterface $entity)
$diff = $right - $left + 1;
if ($diff > 2) {
$this->_table->deleteAll(function ($exp) use ($config, $left, $right) {
/* @var \Cake\Database\Expression\QueryExpression $exp */
return $exp
->gte($config['leftField'], $left + 1)
->lte($config['leftField'], $right - 1);
});
/* @var \Cake\Database\Expression\QueryExpression $expression */
$expression = $this->_scope($this->_table->find())
->where(function ($exp) use ($config, $left, $right) {
return $exp
->gte($config['leftField'], $left + 1)
->lte($config['leftField'], $right - 1);
})
->clause('where');
$this->_table->deleteAll($expression);
}
$this->_sync($diff, '-', "> {$right}");

0 comments on commit 66bfde9

Please sign in to comment.
You can’t perform that action at this time.