diff --git a/classes/monograph/ChapterDAO.php b/classes/monograph/ChapterDAO.php index 4c03f8eac9d..76f02bf320a 100644 --- a/classes/monograph/ChapterDAO.php +++ b/classes/monograph/ChapterDAO.php @@ -318,7 +318,7 @@ public function pubIdExists(string $pubIdType, string $pubId, int $excludePubObj return DB::table('submission_chapter_settings AS scs') ->join('submission_chapters AS sc', 'scs.chapter_id', '=', 'sc.chapter_id') ->join('publications AS p', 'sc.publication_id', '=', 'p.publication_id') - ->join('submissions AS s', 'p.submission_id', '=', 's.submisison_id') + ->join('submissions AS s', 'p.submission_id', '=', 's.submission_id') ->where('scs.setting_name', '=', "pub-id::{$pubIdType}") ->where('scs.setting_value', '=', $pubId) ->where('sc.chapter_id', '<>', $excludePubObjectId) diff --git a/classes/plugins/PubIdPlugin.php b/classes/plugins/PubIdPlugin.php index f8b5188337e..37826a6ced2 100644 --- a/classes/plugins/PubIdPlugin.php +++ b/classes/plugins/PubIdPlugin.php @@ -221,19 +221,17 @@ public function getDAOs() /** * @copydoc PKPPubIdPlugin::checkDuplicate() */ - public function checkDuplicate($pubId, $pubObjectType, $excludeId, int $contextId) + public function checkDuplicate($pubId, $pubObject, int $contextId) { - /** @var ChapterDAO */ - $chapterDao = DAORegistry::getDAO('ChapterDAO'); - foreach ($this->getPubObjectTypes() as $type => $fqcn) { - if ($type === 'Chapter') { - $excludeTypeId = $type === $pubObjectType ? $excludeId : null; - if ($chapterDao->pubIdExists($this->getPubIdType(), $pubId, $excludeTypeId, $contextId)) { - return false; - } + $allowedPubObjectTypes = $this->getPubObjectTypes(); + if ($pubObject instanceof $allowedPubObjectTypes['Chapter']) { + /** @var ChapterDAO */ + $chapterDao = DAORegistry::getDAO('ChapterDAO'); + if ($chapterDao->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/classes/press/PressDAO.php b/classes/press/PressDAO.php index 86fe5e98757..d90df4c39ff 100644 --- a/classes/press/PressDAO.php +++ b/classes/press/PressDAO.php @@ -1,4 +1,5 @@ Repo::submission()->dao, + Application::ASSOC_TYPE_PUBLICATION => Repo::publication()->dao, Application::ASSOC_TYPE_CHAPTER => DAORegistry::getDAO('ChapterDAO'), Application::ASSOC_TYPE_REPRESENTATION => Application::getRepresentationDAO(), Application::ASSOC_TYPE_SUBMISSION_FILE => Repo::submissionFile()->dao, diff --git a/classes/publicationFormat/PublicationFormatDAO.php b/classes/publicationFormat/PublicationFormatDAO.php index 9a94ce5047c..e3cda37c496 100644 --- a/classes/publicationFormat/PublicationFormatDAO.php +++ b/classes/publicationFormat/PublicationFormatDAO.php @@ -1,4 +1,5 @@ join('publications AS p', 'p.publication_id', '=', 'pf.publication_id') ->join('submissions AS s', 's.submission_id', '=', 'p.submission_id') ->where('pft.setting_name', '=', "pub-id::{$pubIdType}") + ->where('pft.setting_value', '=', $pubId) ->where('pf.publication_format_id', '<>', $excludePubObjectId) ->where('s.context_id', '=', $contextId) ->count() > 0; diff --git a/plugins/pubIds/urn/URNPubIdPlugin.php b/plugins/pubIds/urn/URNPubIdPlugin.php index d5491b17824..cf090929b7c 100644 --- a/plugins/pubIds/urn/URNPubIdPlugin.php +++ b/plugins/pubIds/urn/URNPubIdPlugin.php @@ -286,7 +286,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)) {