From 8d030cea64c0e5934e4dbf5fc56fab87c7e253bb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Nov 2010 09:52:40 -0800 Subject: 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. --- modules/gallery/models/item.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/gallery/models') 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"); -- cgit v1.2.3