From 4871374673a33eaf272462167888c8e7c03ebf80 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 30 Jan 2017 16:07:01 -0500 Subject: [PATCH] Don't modify options object passed to DataObject.save() --- chrome/content/zotero/xpcom/data/dataObject.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index 35aedb5a36..179ceb9642 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -790,10 +790,9 @@ Zotero.DataObject.prototype.editCheck = function () { * @return {Promise} Promise for itemID of new item, * TRUE on item update, or FALSE if item was unchanged */ -Zotero.DataObject.prototype.save = Zotero.Promise.coroutine(function* (options) { - options = options || {}; +Zotero.DataObject.prototype.save = Zotero.Promise.coroutine(function* (options = {}) { var env = { - options: options, + options: Object.assign({}, options), transactionOptions: {} }; @@ -880,8 +879,8 @@ Zotero.DataObject.prototype.save = Zotero.Promise.coroutine(function* (options) }); -Zotero.DataObject.prototype.saveTx = function (options) { - options = options || {}; +Zotero.DataObject.prototype.saveTx = function (options = {}) { + options = Object.assign({}, options); options.tx = true; return this.save(options); } @@ -1129,7 +1128,9 @@ Zotero.DataObject.prototype.erase = Zotero.Promise.coroutine(function* (options throw new Error("'options' must be an object"); } - var env = { options }; + var env = { + options: Object.assign({}, options) + }; if (!env.options.tx && !Zotero.DB.inTransaction()) { Zotero.logError("erase() called on Zotero." + this._ObjectType + " without a wrapping "