From c631bc4257e18cf0922a9cebe9460bcf3cd99860 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 10 Jan 2017 18:01:45 -0500 Subject: [PATCH] Default to creatorType: "author" if missing Apparently in 4.0 we defaulted to 'author' if a creatorType wasn't passed. To avoid lots of errors like the one fixed in https://github.com/zotero/translators/commit/dd0094893af003b8f545bfae1ec440fc4199c261, add a similar fallback for 5.0 and log a warning (though not with the translator name, unfortunately). --- .../zotero/xpcom/translation/translate_item.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 968c2333f..8c5c60c89 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -101,6 +101,7 @@ Zotero.Translate.ItemSaver.prototype = { } else { newItem = new Zotero.Item(type); newItem.libraryID = this._libraryID; + if (item.creators) this._cleanCreators(item.creators); if(item.tags) item.tags = this._cleanTags(item.tags); // Need to handle these specially. Put them in a separate object to @@ -651,7 +652,16 @@ Zotero.Translate.ItemSaver.prototype = { yield myNote.save(); return myNote; }), - + + _cleanCreators: function (creators) { + creators.forEach(creator => { + if (!creator.creatorType) { + Zotero.warn(".creatorType missing in creator -- update translator code"); + creator.creatorType = "author"; + } + }); + }, + /** * Remove automatic tags if automatic tags pref is on, and set type * to automatic if forced