From d95d8f294dcb0623950481ac910c78dcfb47472d Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 5 Jul 2026 16:40:17 -0400 Subject: [PATCH] Fix serialization of the result level seeded for a migrated childNote The condition seeded by _loadConditions() used `mode: undefined`, but toJSON() only omits the "/mode" suffix when the mode is exactly false (what parseCondition() returns), so a saved search migrated from the obsolete childNote condition serialized -- and synced -- the condition as "resultLevel/undefined". --- chrome/content/zotero/xpcom/data/searches.js | 4 +++- test/tests/searchTest.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/searches.js b/chrome/content/zotero/xpcom/data/searches.js index 1b64006a4a..1189801454 100644 --- a/chrome/content/zotero/xpcom/data/searches.js +++ b/chrome/content/zotero/xpcom/data/searches.js @@ -198,7 +198,9 @@ Zotero.Searches = function () { search._conditions[id] = { id, condition: 'resultLevel', - mode: undefined, + // No mode -- parseCondition() uses false, and toJSON() only omits the + // "/mode" suffix for an exact false + mode: false, operator: 'item', value: '' }; diff --git a/test/tests/searchTest.js b/test/tests/searchTest.js index a079e8c19b..8bd81a2c0b 100644 --- a/test/tests/searchTest.js +++ b/test/tests/searchTest.js @@ -69,14 +69,15 @@ describe("Zotero.Search", function () { var resultLevel = conds.find(c => c.condition == 'resultLevel'); assert.ok(resultLevel); assert.equal(resultLevel.operator, 'item'); + assert.sameMembers(s.toJSON().conditions.map(c => c.condition), ['note', 'resultLevel']); assert.sameMembers(await s.search(), [item.id]); await item.eraseTx(); await s.eraseTx(); }); }); - - + + describe("#save()", function () { it("should fail without a name", async function () { var s = new Zotero.Search;