Prevent setting search .name to empty value

Prevents bug in zotero-citation plugin (at least on macOS) from creating
a search that breaks syncing

We were already checking for a missing name in `saveTx()`, but the
plugin is saving the same search twice in rapid succession, the second
time without a name, and the second attempt clears the search object's
name value after the first save's `_initSave()` check and before its SQL
write. The second save fails, but the first save goes through without a
name, resulting in a sync error.

https://forums.zotero.org/discussion/104274/id-1702002152-cannot-sync
https://github.com/MuiseDestiny/zotero-citation/issues/31
This commit is contained in:
Dan Stillman 2023-04-11 23:48:07 -04:00
parent cadfca7475
commit 33ef7b1641
2 changed files with 13 additions and 1 deletions

View file

@ -1,4 +1,11 @@
describe("Zotero.Search", function() {
describe("#name", function () {
it("should fail if empty", async function () {
var s = new Zotero.Search();
assert.throws(() => s.name = '');
});
});
describe("#addCondition()", function () {
it("should convert old-style 'collection' condition value", function* () {
var col = yield createDataObject('collection');