Browse Source

Single tree shift() fix

tags/v1.0.1
PaulZi 9 years ago
parent
commit
c19c4d4f53
  1. 4
      NestedSetsBehavior.php

4
NestedSetsBehavior.php

@ -617,7 +617,7 @@ class NestedSetsBehavior extends Behavior
protected function shift($from, $to, $delta, $tree = null) protected function shift($from, $to, $delta, $tree = null)
{ {
if ($delta !== 0 && ($to === null || $to >= $from)) { if ($delta !== 0 && ($to === null || $to >= $from)) {
if ($tree === null) { if ($this->treeAttribute !== null && $tree === null) {
$tree = $this->owner->getAttribute($this->treeAttribute); $tree = $this->owner->getAttribute($this->treeAttribute);
} }
foreach ([$this->leftAttribute, $this->rightAttribute] as $i => $attribute) { foreach ([$this->leftAttribute, $this->rightAttribute] as $i => $attribute) {
@ -626,7 +626,7 @@ class NestedSetsBehavior extends Behavior
[ [
'and', 'and',
$to === null ? ['>=', $attribute, $from] : ['between', $attribute, $from, $to], $to === null ? ['>=', $attribute, $from] : ['between', $attribute, $from, $to],
[$this->treeAttribute => $tree], $this->treeAttribute !== null ? [$this->treeAttribute => $tree] : [],
] ]
); );
} }

Loading…
Cancel
Save