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
dd0094893a,
add a similar fallback for 5.0 and log a warning (though not with the
translator name, unfortunately).
This commit is contained in:
Dan Stillman 2017-01-10 18:01:45 -05:00
parent 97f5c41aff
commit c631bc4257

View file

@ -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