From db0bd566888566b035cd3c6adf6f956c679f0c55 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 22 Feb 2021 03:22:52 -0500 Subject: [PATCH] Prevent possible error if schema check occurs before schema update Not sure if this can happen, but if there's any way for the schema integrity check to run before the global schema is updated, use -1 for the annotation itemTypeID. --- chrome/content/zotero/xpcom/schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 19374f162a..6f5fddb2bd 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -1799,9 +1799,9 @@ Zotero.Schema = new function(){ var noteID = parseInt(yield Zotero.DB.valueQueryAsync( "SELECT itemTypeID FROM itemTypes WHERE typeName='note'" )); - var annotationID = parseInt(yield Zotero.DB.valueQueryAsync( + var annotationID = parseInt((yield Zotero.DB.valueQueryAsync( "SELECT itemTypeID FROM itemTypes WHERE typeName='annotation'" - )); + )) || -1); // The first position is for testing and the second is for repairing. Can be either SQL // statements or promise-returning functions. For statements, the repair entry can be either