diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 0274e0b67..aeb41e1b4 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -118,7 +118,16 @@ Zotero.DataObjects.prototype.get = function (ids) { let id = ids[i]; // Check if already loaded if (!this._objectCache[id]) { - throw new Zotero.Exception.UnloadedDataException(this._ZDO_Object + " " + id + " not yet loaded"); + // If unloaded id is registered, throw an error + if (this._objectKeys[id]) { + throw new Zotero.Exception.UnloadedDataException( + this._ZDO_Object + " " + id + " not yet loaded" + ); + } + // Otherwise ignore (which means returning false for a single id) + else { + continue; + } } toReturn.push(this._objectCache[id]); } diff --git a/test/tests/dataObjectsTest.js b/test/tests/dataObjectsTest.js index 9bc3285c3..448d51cb8 100644 --- a/test/tests/dataObjectsTest.js +++ b/test/tests/dataObjectsTest.js @@ -3,6 +3,12 @@ describe("Zotero.DataObjects", function () { var types = ['collection', 'item', 'search']; + describe("#get()", function () { + it("should return false for nonexistent objects", function* () { + assert.isFalse(Zotero.Items.get(3464363)); + }); + }); + describe("#getLibraryAndKeyFromID()", function () { it("should return a libraryID and key within a transaction", function* () { for (let type of types) {