From d8f8d8a3f88fc8f3ad9e821660f9bc1090265593 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 24 Jun 2017 01:22:05 -0400 Subject: [PATCH] Fix infinite loop restoring from trash if item has itself as relation --- chrome/content/zotero/xpcom/data/item.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 0db520131..226292171 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -1538,6 +1538,14 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { 'item', predicate, thisURI ); for (let mergeItem of mergeItems) { + // An item shouldn't have itself as a dc:replaces relation, but if it does it causes an + // infinite loop + if (mergeItem.id == this.id) { + Zotero.logError(`Item ${this.libraryKey} has itself as a ${predicate} relation`); + this.removeRelation(predicate, thisURI); + continue; + } + mergeItem.removeRelation(predicate, thisURI); yield mergeItem.save({ skipDateModifiedUpdate: true