From 920ab2a4f90292029b62bf36fd23f87fe984690a Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Thu, 25 May 2023 20:14:04 +0300 Subject: [PATCH 1/4] pkp/pkp-lib#8333 Moved migration file --- .../v3_5_0/I8333_AddMissingForeignKeys.php | 33 +++++++++++++++++++ dbscripts/xml/upgrade.xml | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php diff --git a/classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php b/classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php new file mode 100644 index 0000000000..fc3a255971 --- /dev/null +++ b/classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php @@ -0,0 +1,33 @@ + + @@ -121,7 +122,6 @@ - From 4e0c352b8517661055ad00a4db630e3a3e3d549b Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Wed, 24 Jul 2024 01:27:53 +0300 Subject: [PATCH 2/4] pkp/pkp-lib#8333 Typing --- classes/file/PublicFileManager.php | 2 +- classes/oai/ops/OAIDAO.php | 13 ++++--------- classes/oai/ops/ServerOAI.php | 6 ++++-- classes/publication/Publication.php | 4 +--- classes/section/Section.php | 8 ++++---- classes/server/ServerDAO.php | 6 ++---- classes/submission/DAO.php | 2 +- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/classes/file/PublicFileManager.php b/classes/file/PublicFileManager.php index f000880e04..ae23890535 100644 --- a/classes/file/PublicFileManager.php +++ b/classes/file/PublicFileManager.php @@ -24,7 +24,7 @@ class PublicFileManager extends PKPPublicFileManager /** * @copydoc PKPPublicFileManager::getContextFilesPath() */ - public function getContextFilesPath($contextId) + public function getContextFilesPath(int $contextId) { return Config::getVar('files', 'public_files_dir') . '/contexts/' . (int) $contextId; } diff --git a/classes/oai/ops/OAIDAO.php b/classes/oai/ops/OAIDAO.php index bfbbd4549d..ef02d74ddf 100644 --- a/classes/oai/ops/OAIDAO.php +++ b/classes/oai/ops/OAIDAO.php @@ -58,16 +58,11 @@ public function __construct() /** * Cached function to get a server * - * @param int $serverId - * * @return object */ - public function &getServer($serverId) + public function getServer(int $serverId) { - if (!isset($this->serverCache[$serverId])) { - $this->serverCache[$serverId] = $this->serverDao->getById($serverId); - } - return $this->serverCache[$serverId]; + return $this->serverCache[$serverId] ??= $this->serverDao->getById($serverId); } /** @@ -92,14 +87,14 @@ public function &getSection($sectionId) /** * Return hierarchy of OAI sets (servers plus server sections). * - * @param int $serverId * @param int $offset * @param int $total * * @return array OAISet + * * @hook OAIDAO::getServerSets [[$this, $serverId, $offset, $limit, $total, &$sets]] */ - public function &getServerSets($serverId, $offset, $limit, &$total) + public function &getServerSets(int $serverId, $offset, $limit, &$total) { if (isset($serverId)) { $servers = [$this->serverDao->getById($serverId)]; diff --git a/classes/oai/ops/ServerOAI.php b/classes/oai/ops/ServerOAI.php index 3a2e4690f3..4f2434d7a9 100644 --- a/classes/oai/ops/ServerOAI.php +++ b/classes/oai/ops/ServerOAI.php @@ -38,8 +38,7 @@ class ServerOAI extends OAI /** @var Server associated server object */ public $server; - /** @var int|null Server ID; null if no server */ - public $serverId; + public ?int $serverId; /** @var OAIDAO DAO for retrieving OAI records/tokens from database */ public $dao; @@ -182,6 +181,7 @@ public function record($identifier) /** * @copydoc OAI::records() + * * @hook ServerOAI::records [[$this, $from, $until, $set, $offset, $limit, &$total, &$records]] */ public function records($metadataPrefix, $from, $until, $set, $offset, $limit, &$total) @@ -201,6 +201,7 @@ public function records($metadataPrefix, $from, $until, $set, $offset, $limit, & /** * @copydoc OAI::identifiers() + * * @hook ServerOAI::identifiers [[$this, $from, $until, $set, $offset, $limit, &$total, &$records]] */ public function identifiers($metadataPrefix, $from, $until, $set, $offset, $limit, &$total) @@ -220,6 +221,7 @@ public function identifiers($metadataPrefix, $from, $until, $set, $offset, $limi /** * @copydoc OAI::sets() + * * @hook ServerOAI::sets [[$this, $offset, $limit, &$total, &$sets]] */ public function sets($offset, $limit, &$total) diff --git a/classes/publication/Publication.php b/classes/publication/Publication.php index 353f98ba12..342fcc6a77 100644 --- a/classes/publication/Publication.php +++ b/classes/publication/Publication.php @@ -30,11 +30,9 @@ class Publication extends PKPPublication /** * Get the URL to a localized cover image * - * @param int $contextId - * * @return string */ - public function getLocalizedCoverImageUrl($contextId) + public function getLocalizedCoverImageUrl(int $contextId) { $coverImage = $this->getLocalizedData('coverImage'); diff --git a/classes/section/Section.php b/classes/section/Section.php index f6892181b3..ca149d8e73 100644 --- a/classes/section/Section.php +++ b/classes/section/Section.php @@ -36,7 +36,7 @@ public function getAbbrev(?string $locale): string|array|null return $this->getData('abbrev', $locale); } - public function setAbbrev(string|array $abbrev, string $locale = null): void + public function setAbbrev(string|array $abbrev, ?string $locale = null): void { $this->setData('abbrev', $abbrev, $locale); } @@ -51,7 +51,7 @@ public function getPolicy(?string $locale): string|array|null return $this->getData('policy', $locale); } - public function setPolicy(string|array $policy, string $locale = null): void + public function setPolicy(string|array $policy, ?string $locale = null): void { $this->setData('policy', $policy, $locale); } @@ -186,7 +186,7 @@ public function getIdentifyType(?string $locale): string|array|null /** * Set string identifying type of items in this section. */ - public function setIdentifyType(string|array $identifyType, string $locale = null): void + public function setIdentifyType(string|array $identifyType, ?string $locale = null): void { $this->setData('identifyType', $identifyType, $locale); } @@ -230,7 +230,7 @@ public function getDescription(?string $locale): string|array|null /** * Set series description. */ - public function setDescription(string|array $description, string $locale = null): void + public function setDescription(string|array $description, ?string $locale = null): void { $this->setData('description', $description, $locale); } diff --git a/classes/server/ServerDAO.php b/classes/server/ServerDAO.php index 33ca32ac14..1d93d6d2f1 100644 --- a/classes/server/ServerDAO.php +++ b/classes/server/ServerDAO.php @@ -77,12 +77,11 @@ public function getTitles($enabledOnly = false) /** * Delete the public IDs of all publishing objects in a server. * - * @param int $serverId * @param string $pubIdType One of the NLM pub-id-type values or * 'other::something' if not part of the official NLM list * (see ). */ - public function deleteAllPubIds($serverId, $pubIdType) + public function deleteAllPubIds(int $serverId, $pubIdType) { Repo::galley()->dao->deleteAllPubIds($serverId, $pubIdType); Repo::submissionFile()->dao->deleteAllPubIds($serverId, $pubIdType); @@ -93,7 +92,6 @@ public function deleteAllPubIds($serverId, $pubIdType) * Check whether the given public ID exists for any publishing * object in a server. * - * @param int $serverId * @param string $pubIdType One of the NLM pub-id-type values or * 'other::something' if not part of the official NLM list * (see ). @@ -106,7 +104,7 @@ public function deleteAllPubIds($serverId, $pubIdType) * @return bool */ public function anyPubIdExists( - $serverId, + int $serverId, $pubIdType, $pubId, $assocType = MetadataTypeDescription::ASSOC_TYPE_ANY, diff --git a/classes/submission/DAO.php b/classes/submission/DAO.php index 37bbba8013..41a3baa0d3 100644 --- a/classes/submission/DAO.php +++ b/classes/submission/DAO.php @@ -46,7 +46,7 @@ public function deleteById(int $id): int * * @return DAOResultFactory */ - public function getExportable($contextId, $pubIdType = null, $title = null, $author = null, $issueId = null, $pubIdSettingName = null, $pubIdSettingValue = null, $rangeInfo = null) + public function getExportable(int $contextId, $pubIdType = null, $title = null, $author = null, $issueId = null, $pubIdSettingName = null, $pubIdSettingValue = null, $rangeInfo = null) { $q = DB::table('submissions', 's') ->leftJoin('publications AS p', 's.current_publication_id', '=', 'p.publication_id') From c81c679830487a44c666d1b80689e60ecc26bbfb Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Wed, 24 Jul 2024 01:29:17 +0300 Subject: [PATCH 3/4] pkp/pkp-lib#8333 Replaced CONTEXT_ID_NONE by SITE_CONTEXT_ID --- pages/oai/OAIHandler.php | 3 ++- pages/preprints/SectionsHandler.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pages/oai/OAIHandler.php b/pages/oai/OAIHandler.php index 2b18e3aec8..aae53b90ae 100644 --- a/pages/oai/OAIHandler.php +++ b/pages/oai/OAIHandler.php @@ -16,6 +16,7 @@ namespace APP\pages\oai; +use APP\core\Application; use APP\handler\Handler; use APP\oai\ops\ServerOAI; use Firebase\JWT\Key; @@ -42,7 +43,7 @@ public function index($args, $request) PluginRegistry::loadCategory('oaiMetadataFormats', true); $oai = new ServerOAI(new OAIConfig($request->url(null, 'oai'), Config::getVar('oai', 'repository_id'))); - if (!$request->getServer() && $request->getRouter()->getRequestedContextPath($request) != 'index') { + if (!$request->getServer() && $request->getRouter()->getRequestedContextPath($request) != Application::SITE_CONTEXT_PATH) { $dispatcher = $request->getDispatcher(); return $dispatcher->handle404(); } diff --git a/pages/preprints/SectionsHandler.php b/pages/preprints/SectionsHandler.php index 8dc7b79651..730ce52697 100644 --- a/pages/preprints/SectionsHandler.php +++ b/pages/preprints/SectionsHandler.php @@ -60,7 +60,7 @@ public function section($args, $request) $sectionPath = $args[0] ?? null; $page = isset($args[1]) && ctype_digit((string) $args[1]) ? (int) $args[1] : 1; $context = $request->getContext(); - $contextId = $context ? $context->getId() : Application::CONTEXT_ID_NONE; + $contextId = $context?->getId() ?? Application::SITE_CONTEXT_ID; // The page $arg can only contain an integer that's not 1. The first page // URL does not include page $arg From 306f602f8ac55beaf9a3ac288f203dc2942e9743 Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Fri, 26 May 2023 12:22:27 +0300 Subject: [PATCH 4/4] pkp/pkp-lib#8333 Submodule update ##jonasraoni/feature-main-8333-add-remaining-fks## --- lib/pkp | 2 +- plugins/generic/acron | 2 +- plugins/generic/customBlockManager | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pkp b/lib/pkp index ff493fc2d5..1d6663be9c 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit ff493fc2d5e48deea7aac9ed5578bfefe9562686 +Subproject commit 1d6663be9ca3f83ce27cd2078629fc1c3b30e003 diff --git a/plugins/generic/acron b/plugins/generic/acron index dede22d5d7..a1545b0017 160000 --- a/plugins/generic/acron +++ b/plugins/generic/acron @@ -1 +1 @@ -Subproject commit dede22d5d7d18fdd6fddf6b7dad6f034c8ae1fc3 +Subproject commit a1545b0017a57a6681ab727783ab870998e75361 diff --git a/plugins/generic/customBlockManager b/plugins/generic/customBlockManager index 07a20379a3..9d92d839c3 160000 --- a/plugins/generic/customBlockManager +++ b/plugins/generic/customBlockManager @@ -1 +1 @@ -Subproject commit 07a20379a345083998f489533582886bfe3c4a27 +Subproject commit 9d92d839c3c7a8299eea2bc736f23c90bece1120