From 3576a57f0777a0a82a5698eddd7de41c815a9cd0 Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Wed, 15 Jan 2025 04:54:22 +0100 Subject: [PATCH 1/3] pkp/pkp-lib#10821 fix checkDuplicate, anyPubIdExists, pubIdExists --- classes/issue/DAO.php | 3 ++- classes/journal/JournalDAO.php | 2 +- classes/plugins/PubIdPlugin.php | 16 +++++++--------- plugins/pubIds/urn/URNPubIdPlugin.php | 5 +++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/classes/issue/DAO.php b/classes/issue/DAO.php index c76f9e2b479..a981d79a2c8 100644 --- a/classes/issue/DAO.php +++ b/classes/issue/DAO.php @@ -1,4 +1,5 @@ join('issues AS i', 'ist.issue_id', '=', 'i.issue_id') ->where('ist.setting_name', '=', "pub-id::{$pubIdType}") - ->where('ist.setting_value', '<>', $pubId) + ->where('ist.setting_value', '=', $pubId) ->where('i.issue_id', '<>', $excludePubObjectId) ->where('i.journal_id', '=', $contextId) ->count() > 0; diff --git a/classes/journal/JournalDAO.php b/classes/journal/JournalDAO.php index 68c2c778261..5b1b716e38b 100644 --- a/classes/journal/JournalDAO.php +++ b/classes/journal/JournalDAO.php @@ -118,7 +118,7 @@ public function anyPubIdExists( $pubObjectDaos = [ Application::ASSOC_TYPE_ISSUE => Repo::issue()->dao, Application::ASSOC_TYPE_PUBLICATION => Repo::publication()->dao, - Application::ASSOC_TYPE_GALLEY => Application::getRepresentationDAO(), + Application::ASSOC_TYPE_REPRESENTATION => Application::getRepresentationDAO(), Application::ASSOC_TYPE_ISSUE_GALLEY => DAORegistry::getDAO('IssueGalleyDAO'), Application::ASSOC_TYPE_SUBMISSION_FILE => Repo::submissionFile()->dao, ]; diff --git a/classes/plugins/PubIdPlugin.php b/classes/plugins/PubIdPlugin.php index e0102724d21..37e743402fc 100644 --- a/classes/plugins/PubIdPlugin.php +++ b/classes/plugins/PubIdPlugin.php @@ -140,18 +140,16 @@ public function getPubObjectTypes() /** * @copydoc PKPPubIdPlugin::checkDuplicate() */ - public function checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId) + public function checkDuplicate($pubId, $pubObject, $contextId) { - foreach ($this->getPubObjectTypes() as $type => $fqcn) { - if ($type === 'Issue') { - $excludeTypeId = $type === $pubObjectType ? $excludeId : null; - if (Repo::issue()->dao->pubIdExists($this->getPubIdType(), $pubId, $excludeTypeId, $contextId)) { - return false; - } + $allowedPubObjectTypes = $this->getPubObjectTypes(); + if ($pubObject instanceof $allowedPubObjectTypes['Issue']) { + if (Repo::issue()->dao->pubIdExists($this->getPubIdType(), $pubId, $pubObject->getId(), $contextId)) { + return false; } + return true; } - - return parent::checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId); + return parent::checkDuplicate($pubId, $pubObject, $contextId); } /** diff --git a/plugins/pubIds/urn/URNPubIdPlugin.php b/plugins/pubIds/urn/URNPubIdPlugin.php index 7e0423a4c9a..c70af35ffb9 100755 --- a/plugins/pubIds/urn/URNPubIdPlugin.php +++ b/plugins/pubIds/urn/URNPubIdPlugin.php @@ -21,6 +21,7 @@ use APP\plugins\PubIdPlugin; use APP\plugins\pubIds\urn\classes\form\FieldPubIdUrn; use APP\plugins\pubIds\urn\classes\form\FieldTextUrn; +use APP\plugins\pubIds\urn\classes\form\URNSettingsForm; use APP\template\TemplateManager; use PKP\components\forms\FormComponent; use PKP\components\forms\publication\PKPPublicationIdentifiersForm; @@ -157,7 +158,7 @@ public function getPubIdAssignFile() */ public function instantiateSettingsForm($contextId) { - return new classes\form\URNSettingsForm($this, $contextId); + return new URNSettingsForm($this, $contextId); } /** @@ -312,7 +313,7 @@ public function validatePublicationUrn(string $hookName, array $args): void if (strpos($props['pub-id::other::urn'], $urnPrefix) !== 0) { $urnErrors[] = __('plugins.pubIds.urn.editor.missingPrefix', ['urnPrefix' => $urnPrefix]); } - if (!$this->checkDuplicate($props['pub-id::other::urn'], 'Publication', $submission->getId(), $contextId)) { + if (!$this->checkDuplicate($props['pub-id::other::urn'], $publication, $contextId)) { $urnErrors[] = $this->getNotUniqueErrorMsg(); } if (!empty($urnErrors)) { From 8915fe963a660c472353e36b837074351af82edd Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Mon, 20 Jan 2025 16:45:31 +0100 Subject: [PATCH 2/3] pkp/pkp-lib#10821 fix syntax error in FieldTextUrn.js --- plugins/pubIds/urn/js/FieldTextUrn.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/pubIds/urn/js/FieldTextUrn.js b/plugins/pubIds/urn/js/FieldTextUrn.js index 62d8d5fb1c1..cfa33ef32f9 100644 --- a/plugins/pubIds/urn/js/FieldTextUrn.js +++ b/plugins/pubIds/urn/js/FieldTextUrn.js @@ -55,7 +55,6 @@ pkp.registry.registerComponent('FieldTextUrn', { ' :id="describedByErrorId"' + ' :messages="errors"' + ' />' + - ' ' + ' ' + ' ', props: { From 952c6007a9524dcdbb28535f9478d718b2c7e24a Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Mon, 20 Jan 2025 18:25:55 +0100 Subject: [PATCH 3/3] pkp/pkp-lib#10821 submodule update ##bozana/10821## --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index f50463790b3..3fdd61a86aa 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit f50463790b35216af4495257c9d9e06fc3be060d +Subproject commit 3fdd61a86aa5ba6e72aac38304de38dea4c540b5