diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-12-04 11:12:24 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-12-04 11:13:20 -0800 |
commit | 5c107be9033ae48f781c8430702458f613e791ee (patch) | |
tree | 5fdaf68aa4b2a114328da249cc0948714e3f5684 | |
parent | c9e6869c681fa6579d1858cea45ec94eb0972f30 (diff) |
Reload relevant models after acquiring a lock so that we don't make
database calls based on obsolete data, which can lead to data corruption.
Fixes ticket #926.
-rw-r--r-- | modules/gallery/libraries/ORM_MPTT.php | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php index 83d2445c..ebd7abc2 100644 --- a/modules/gallery/libraries/ORM_MPTT.php +++ b/modules/gallery/libraries/ORM_MPTT.php @@ -48,6 +48,7 @@ class ORM_MPTT_Core extends ORM { */ function add_to_parent($parent) { $this->lock(); + $parent->reload(); // Assume that the prior lock holder may have changed the parent try { // Make a hole in the parent for this new item @@ -91,6 +92,7 @@ class ORM_MPTT_Core extends ORM { } $this->lock(); + $this->reload(); // Assume that the prior lock holder may have changed this entry try { $this->db->query( "UPDATE {{$this->table_name}} SET `left_ptr` = `left_ptr` - 2 WHERE `left_ptr` > {$this->right_ptr}"); @@ -224,6 +226,8 @@ class ORM_MPTT_Core extends ORM { $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 |