summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries/ORM_MPTT.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-11-18 09:52:40 -0800
committerBharat Mediratta <bharat@menalto.com>2010-11-18 09:52:40 -0800
commit8d030cea64c0e5934e4dbf5fc56fab87c7e253bb (patch)
treecbdfe98d8e398c978106394b81a18a316bafa0a6 /modules/gallery/libraries/ORM_MPTT.php
parentdca9b5f3fc8e80ee0667cac88d688e2287b1e7f4 (diff)
Fix a bug where simultaneous deletes of the same item can result in it
deleting the first item row in the database. The root issue is a bug in Kohana that's addressed in dca9b5f3fc8e80ee0667cac88d688e2287b1e7f4 but in this change we deal with the fact that reloading an item can result in an instance of the item that's unloaded. In those cases, we should just ignore it and move on. Fixes #1489.
Diffstat (limited to 'modules/gallery/libraries/ORM_MPTT.php')
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index d8d88e4e..f20fafa0 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -96,12 +96,16 @@ class ORM_MPTT_Core extends ORM {
$item->reload()->delete();
}
- // Deleting children has affected this item
- $this->reload();
+ // Deleting children has affected this item, but we'll reload it below.
}
$this->lock();
$this->reload(); // Assume that the prior lock holder may have changed this entry
+ if (!$this->loaded()) {
+ // Concurrent deletes may result in this item already being gone. Ignore it.
+ return;
+ }
+
try {
db::build()
->update($this->table_name)