From 51aed56d6699367a73cf57fe4214ea24f4d4f881 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 15 Jun 2026 14:33:24 -0400 Subject: [PATCH] Use real PMCID field instead of Extra fallback PMCID is a real, auto-migrated field, so the getExtraField() fallback isn't needed. --- chrome/content/zotero/xpcom/attachments.js | 4 ++-- test/tests/attachmentsTest.js | 10 +++++----- test/tests/server_connectorTest.js | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 9ae7aef4b0..afe7830780 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -1239,7 +1239,7 @@ Zotero.Attachments = new function () { this.canFindFileForItem = function (item) { - let pmcid = item.getField('PMCID') || item.getExtraField('PMCID'); + let pmcid = item.getField('PMCID'); return item.isRegularItem() && !item.isFeedItem && (!!item.getField('DOI') || !!item.getField('url') || !!item.getExtraField('DOI') || !!pmcid) @@ -1276,7 +1276,7 @@ Zotero.Attachments = new function () { var resolvers = []; var doi = item.getField('DOI') || item.getExtraField('DOI'); - var pmcid = item.getField('PMCID') || item.getExtraField('PMCID'); + var pmcid = item.getField('PMCID'); doi = Zotero.Utilities.cleanDOI(doi); if (pmcid) { let matches = pmcid.match(/\bPMC\d+\b/i); diff --git a/test/tests/attachmentsTest.js b/test/tests/attachmentsTest.js index ebc124fc40..726967b091 100644 --- a/test/tests/attachmentsTest.js +++ b/test/tests/attachmentsTest.js @@ -1031,10 +1031,10 @@ describe("Zotero.Attachments", function () { assert.equal(await OS.File.stat(attachment.getFilePath()).size, pdfSize); }); - it("should include a PubMed Central resolver from a PMCID in Extra", async function () { + it("should include a PubMed Central resolver from a PMCID", async function () { var item = createUnsavedDataObject('item', { itemType: 'journalArticle' }); item.setField('title', 'Test'); - item.setField('extra', 'PMCID: PMC9262588'); + item.setField('PMCID', 'PMC9262588'); await item.saveTx(); var resolvers = Zotero.Attachments.getFileResolvers(item, ['oa']); @@ -1051,7 +1051,7 @@ describe("Zotero.Attachments", function () { var item = createUnsavedDataObject('item', { itemType: 'journalArticle' }); item.setField('title', 'Test'); item.setField('DOI', '10.1093/nar/gkac173'); - item.setField('extra', 'PMCID: PMC9262588'); + item.setField('PMCID', 'PMC9262588'); await item.saveTx(); var resolvers = Zotero.Attachments.getFileResolvers(item, ['oa']); @@ -1064,10 +1064,10 @@ describe("Zotero.Attachments", function () { assert.isFunction(resolvers[1]); }); - it("should allow finding files for an item with a PMCID in Extra", async function () { + it("should allow finding files for an item with a PMCID", async function () { var item = createUnsavedDataObject('item', { itemType: 'journalArticle' }); item.setField('title', 'Test'); - item.setField('extra', 'PMCID: PMC9262588'); + item.setField('PMCID', 'PMC9262588'); await item.saveTx(); assert.isTrue(Zotero.Attachments.canFindFileForItem(item)); diff --git a/test/tests/server_connectorTest.js b/test/tests/server_connectorTest.js index c9bcfbd0a0..5759c4b22a 100644 --- a/test/tests/server_connectorTest.js +++ b/test/tests/server_connectorTest.js @@ -701,7 +701,7 @@ describe("Connector Server", function () { assert.isTrue(JSON.parse(response.responseText)); }); - it("should respond with 'true' if the item has a PMCID fallback", async function () { + it("should respond with 'true' if the item has a PMCID", async function () { const sessionID = Zotero.Utilities.randomString(); const itemID = Zotero.Utilities.randomString(); const body = { @@ -711,7 +711,7 @@ describe("Connector Server", function () { id: itemID, itemType: "journalArticle", title: "Test Article with PMCID", - extra: "PMCID: PMC9262588", + PMCID: "PMC9262588", } ] };