diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index b8a6985b1c..af05f64df1 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -3973,7 +3973,19 @@ Zotero.Item.prototype.erase = function() { } Zotero.DB.query('DELETE FROM itemData WHERE itemID=?', this.id); - Zotero.DB.query('DELETE FROM items WHERE itemID=?', this.id); + + try { + Zotero.DB.query('DELETE FROM items WHERE itemID=?', this.id); + } + catch (e) { + // If deletion fails, try to correct a few things that have come up before + Zotero.debug("Item deletion failed -- trying to fix", 2); + Zotero.DB.query('DELETE FROM fulltextItemWords WHERE itemID=?', this.id); + Zotero.DB.query('DELETE FROM itemTags WHERE itemID=?', this.id); + + // And then try again + Zotero.DB.query('DELETE FROM items WHERE itemID=?', this.id); + } try { Zotero.DB.commitTransaction();