in move_to(), move the lock to before we do any calculations so that we have the latest data.

This commit is contained in:
Bharat Mediratta
2010-01-18 21:40:00 -08:00
parent b4e6834a28
commit efa4e230da

View File

@@ -232,6 +232,10 @@ class ORM_MPTT_Core extends ORM {
throw new Exception("@todo INVALID_TARGET can't move item inside itself");
}
$this->lock();
$this->reload(); // Assume that the prior lock holder may have changed this entry
$target->reload();
$number_to_move = (int)(($this->right_ptr - $this->left_ptr) / 2 + 1);
$size_of_hole = $number_to_move * 2;
$original_left_ptr = $this->left_ptr;
@@ -239,9 +243,6 @@ class ORM_MPTT_Core extends ORM {
$target_right_ptr = $target->right_ptr;
$level_delta = ($target->level + 1) - $this->level;
$this->lock();
$this->reload(); // Assume that the prior lock holder may have changed this entry
$target->reload();
try {
if ($level_delta) {
// Update the levels for the to-be-moved items