From dc11b37cedbef984cc60aec3a372e6e0e06b54d2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 1 Oct 2017 22:05:40 -0400 Subject: [PATCH] Log warning if key not passed to getByLibraryAndKey() --- chrome/content/zotero/xpcom/data/dataObjects.js | 7 ++++--- chrome/content/zotero/xpcom/data/item.js | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 548d8d6bd..40512140e 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -329,9 +329,10 @@ Zotero.DataObjects.prototype.getLibraryAndKeyFromID = function (id) { Zotero.DataObjects.prototype.getIDFromLibraryAndKey = function (libraryID, key) { - if (!libraryID) { - throw new Error("libraryID not provided"); - } + if (!libraryID) throw new Error("Library ID not provided"); + // TEMP: Just warn for now + //if (!key) throw new Error("Key not provided"); + if (!key) Zotero.logError("Key not provided"); return (this._objectIDs[libraryID] && this._objectIDs[libraryID][key]) ? this._objectIDs[libraryID][key] : false; } diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 0c1058ffc..0bc14ddb9 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -1373,7 +1373,9 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { // Parent item (DB update is done below after collection removals) var parentItemKey = this.parentKey; - var parentItemID = this.ObjectsClass.getIDFromLibraryAndKey(this.libraryID, parentItemKey) || null; + var parentItemID = parentItemKey + ? (this.ObjectsClass.getIDFromLibraryAndKey(this.libraryID, parentItemKey) || null) + : null; if (this._changed.parentKey) { if (isNew) { if (!parentItemID) {