commit 0a5ec165fbc3b732b92c27fa1c535bc814224731
parent d93826af1b9a475c4ca4c92c4c6d7ddb05ff6b47
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 9 Jan 2012 13:22:59 -0500
Drop empty creators in ZU.itemToServerJSON() and fix debug comments
Diffstat:
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -1082,7 +1082,7 @@ Zotero.Utilities = {
var typeID = Zotero.ItemTypes.getID(item.itemType);
if(!typeID) {
- Zotero.debug("Translate: Invalid itemType "+item.itemType+"; saving as webpage");
+ Zotero.debug("itemToServerJSON: Invalid itemType "+item.itemType+"; using webpage");
item.itemType = "webpage";
typeID = Zotero.ItemTypes.getID(item.itemType);
}
@@ -1103,6 +1103,11 @@ Zotero.Utilities = {
for(var j=0; j<n; j++) {
var creator = val[j];
+ if(!creator.firstName && !creator.lastName) {
+ Zotero.debug("itemToServerJSON: Silently dropping empty creator");
+ continue;
+ }
+
// Single-field mode
if (!creator.firstName || (creator.fieldMode && creator.fieldMode == 1)) {
var newCreator = {
@@ -1122,7 +1127,7 @@ Zotero.Utilities = {
if(Zotero.CreatorTypes.getID(creator.creatorType)) {
newCreator.creatorType = creator.creatorType;
} else {
- Zotero.debug("Translate: Invalid creator type "+creator.creatorType+"; falling back to author");
+ Zotero.debug("itemToServerJSON: Invalid creator type "+creator.creatorType+"; falling back to author");
}
}
if(!newCreator.creatorType) newCreator.creatorType = "author";
@@ -1141,7 +1146,7 @@ Zotero.Utilities = {
} else if(tag.name) {
tag = tag.name;
} else {
- Zotero.debug("Translate: Discarded invalid tag");
+ Zotero.debug("itemToServerJSON: Discarded invalid tag");
continue;
}
}
@@ -1155,7 +1160,7 @@ Zotero.Utilities = {
var note = val[j];
if(typeof note === "object") {
if(!note.note) {
- Zotero.debug("Translate: Discarded invalid note");
+ Zotero.debug("itemToServerJSON: Discarded invalid note");
continue;
}
note = note.note;
@@ -1182,10 +1187,10 @@ Zotero.Utilities = {
if(Zotero.ItemFields.isValidForType(fieldID, typeID)) {
newItem[field] = val;
} else {
- Zotero.debug("Translate: Discarded field "+field+": field not valid for type "+item.itemType, 3);
+ Zotero.debug("itemToServerJSON: Discarded field "+field+": field not valid for type "+item.itemType, 3);
}
} else {
- Zotero.debug("Translate: Discarded unknown field "+field, 3);
+ Zotero.debug("itemToServerJSON: Discarded unknown field "+field, 3);
}
}