From 297cdc5a1f100e58bb0fd91ae5af3ae37e069cf9 Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Sat, 23 Dec 2023 18:58:45 +0300 Subject: [PATCH 1/2] pkp/pkp-lib#9535 Skipped submission files that have an invalid file stage at the Native XML plugin --- locale/en/manager.po | 3 +++ .../native/filter/SubmissionFileNativeXmlFilter.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/locale/en/manager.po b/locale/en/manager.po index 820c8b921a2..45e61dae8fd 100644 --- a/locale/en/manager.po +++ b/locale/en/manager.po @@ -2263,6 +2263,9 @@ msgstr "" msgid "plugins.importexport.native.error.submissionFileWithoutRevision" msgstr "The submission file {$id} was skipped because it does not have a valid revision." +msgid "plugins.importexport.native.error.submissionFileInvalidFileStage" +msgstr "The submission file {$id} was skipped because it does not have a valid file stage." + msgid "plugins.importexport.native.error.submissionFileRevisionMissing" msgstr "The revision {$revision} of the submission file {$id} was skipped because the file was not found at the path \"{$path}\"." diff --git a/plugins/importexport/native/filter/SubmissionFileNativeXmlFilter.php b/plugins/importexport/native/filter/SubmissionFileNativeXmlFilter.php index b4c22b9f3fb..99b32b6cd0c 100644 --- a/plugins/importexport/native/filter/SubmissionFileNativeXmlFilter.php +++ b/plugins/importexport/native/filter/SubmissionFileNativeXmlFilter.php @@ -81,6 +81,13 @@ public function createSubmissionFileNode(DOMDocument $doc, SubmissionFile $submi $deployment = $this->getDeployment(); $context = $deployment->getContext(); $stageToName = array_flip($deployment->getStageNameStageIdMapping()); + + // Quit if the submission file has an invalid file stage + if (!isset($stageToName[$submissionFile->getFileStage()])) { + $deployment->addWarning(PKPApplication::ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getId(), __('plugins.importexport.native.error.submissionFileInvalidFileStage', ['id' => $submissionFile->getId()])); + return null; + } + $genreDao = DAORegistry::getDAO('GenreDAO'); /** @var GenreDAO $genreDao */ $genre = $genreDao->getById($submissionFile->getData('genreId')); $uploaderUser = Repo::user()->get($submissionFile->getData('uploaderUserId'), true); From 61b0e3510068b530e37142d79e75dd53d1b56b2f Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Sat, 30 Dec 2023 19:52:15 +0300 Subject: [PATCH 2/2] pkp/pkp-lib#9535 Added migration to move zeroed file stages to the submission stage --- .../v3_4_0/I9535_FixEmptyFileStage.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 classes/migration/upgrade/v3_4_0/I9535_FixEmptyFileStage.php diff --git a/classes/migration/upgrade/v3_4_0/I9535_FixEmptyFileStage.php b/classes/migration/upgrade/v3_4_0/I9535_FixEmptyFileStage.php new file mode 100644 index 00000000000..5289caf5b11 --- /dev/null +++ b/classes/migration/upgrade/v3_4_0/I9535_FixEmptyFileStage.php @@ -0,0 +1,37 @@ +where('file_stage', 0) + // To \PKP\submissionFile\SubmissionFile::SUBMISSION_FILE_SUBMISSION + ->update(['file_stage' => 2]); + } + + public function down(): void + { + throw new DowngradeNotSupportedException(); + } +}