commit 4871374673a33eaf272462167888c8e7c03ebf80
parent 835003dd6d3f5f3059d3b7cfff13d80b3454d2c2
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 30 Jan 2017 16:07:01 -0500
Don't modify options object passed to DataObject.save()
Diffstat:
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
@@ -790,10 +790,9 @@ Zotero.DataObject.prototype.editCheck = function () {
* @return {Promise<Integer|Boolean>} 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 "