summaryrefslogtreecommitdiff
path: root/modules/gallery/models/item.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/models/item.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/models/item.php')
-rw-r--r--modules/gallery/models/item.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 891153d1..9016a04a 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -71,6 +71,11 @@ class Item_Model_Core extends ORM_MPTT {
}
public function delete($ignored_id=null) {
+ if (!$this->loaded()) {
+ // Concurrent deletes may result in this item already being gone. Ignore it.
+ return;
+ }
+
if ($this->id == 1) {
$v = new Validation(array("id"));
$v->add_error("id", "cant_delete_root_album");