www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit c631bc4257e18cf0922a9cebe9460bcf3cd99860
parent 97f5c41aff546ce9df71bfd7af9f3e33cbad79f0
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 10 Jan 2017 18:01:45 -0500

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).

Diffstat:
Mchrome/content/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 @@ -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