From 5c6400e21bfa644a12df38cea2bfa487811070f3 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 22 Aug 2025 03:33:09 -0400 Subject: [PATCH] Skip unnecessary SQL query if no attachments in Item#getBestAttachments() This probably shouldn't be SQL at all, but while it is, skip it if not necessary. --- chrome/content/zotero/xpcom/data/item.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 6646d31a6a..6447ff5a94 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -3862,6 +3862,10 @@ Zotero.Item.prototype.getBestAttachments = async function () { throw new Error("getBestAttachments() can only be called on regular items"); } + if (!this.numAttachments()) { + return []; + } + var url = this.getField('url'); var urlFieldID = Zotero.ItemFields.getID('url');