From a1be174c284778df130af54620fc73e4c0de33ba Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt Date: Thu, 13 Aug 2026 17:23:05 +0200 Subject: [PATCH] Fix zero local data object versions (#6016) (cherry picked from commit b8fdee865ac431a6f01b00349cf7a4c5dc2ac24c) --- chrome/content/zotero/xpcom/data/collection.js | 1 + chrome/content/zotero/xpcom/data/item.js | 1 + chrome/content/zotero/xpcom/data/search.js | 1 + test/tests/dataObjectTest.js | 15 +++++++++++++++ 4 files changed, 18 insertions(+) diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index ad25464f89..520ab91923 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -140,6 +140,7 @@ Zotero.Collection.prototype.loadFromRow = function (row) { // Integer or 0 case 'version': + case 'clientVersion': val = val ? parseInt(val) : 0; break; diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 029e0332c6..35aefe9667 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -375,6 +375,7 @@ Zotero.Item.prototype._parseRowData = function (row) { // Integer or 0 case 'version': + case 'clientVersion': val = val ? parseInt(val) : 0; break; diff --git a/chrome/content/zotero/xpcom/data/search.js b/chrome/content/zotero/xpcom/data/search.js index e10b7d1c06..283945027f 100644 --- a/chrome/content/zotero/xpcom/data/search.js +++ b/chrome/content/zotero/xpcom/data/search.js @@ -143,6 +143,7 @@ Zotero.Search.prototype.loadFromRow = function (row) { // Integer or 0 case 'version': + case 'clientVersion': val = val ? parseInt(val) : 0; break; diff --git a/test/tests/dataObjectTest.js b/test/tests/dataObjectTest.js index 2837a666b6..de371967e5 100644 --- a/test/tests/dataObjectTest.js +++ b/test/tests/dataObjectTest.js @@ -61,6 +61,21 @@ describe("Zotero.DataObject", function () { } }); + it("should load 0 as a number", async function () { + for (let type of types) { + let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type); + let obj = await createDataObject(type); + let id = obj.id; + await Zotero.DB.queryAsync( + `UPDATE ${objectsClass.table} SET clientVersion=0 WHERE ${objectsClass.idColumn}=?`, + id + ); + objectsClass.unload(id); + obj = await objectsClass.getAsync(id); + assert.strictEqual(obj.clientVersion, 0, type + " clientVersion mismatch"); + } + }); + it("should increase after modifying object", async function () { for (let type of types) { let obj = await createDataObject(type);