diff --git a/classes/migration/upgrade/v3_4_0/I12140_MissingDecisionConstantsUpdate.php b/classes/migration/upgrade/v3_4_0/I12140_MissingDecisionConstantsUpdate.php
new file mode 100644
index 00000000000..c2f62544eea
--- /dev/null
+++ b/classes/migration/upgrade/v3_4_0/I12140_MissingDecisionConstantsUpdate.php
@@ -0,0 +1,133 @@
+ [WORKFLOW_STAGE_ID_SUBMISSION],
+ 'current_value' => 19,
+ 'updated_value' => 17,
+ ],
+
+ // \PKP\decision\Decision::RECOMMEND_EXTERNAL_REVIEW
+ // OMP 3.3 only offered this at INTERNAL_REVIEW stage
+ // See https://github.com/pkp/pkp-lib/issues/12357
+ [
+ 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
+ 'current_value' => 15,
+ 'updated_value' => 13,
+ ],
+
+ // \PKP\decision\Decision::BACK_FROM_PRODUCTION
+ [
+ 'stage_id' => [WORKFLOW_STAGE_ID_PRODUCTION],
+ 'current_value' => 31,
+ 'updated_value' => 29,
+ ],
+
+ // \PKP\decision\Decision::BACK_FROM_COPYEDITING
+ [
+ 'stage_id' => [WORKFLOW_STAGE_ID_EDITING],
+ 'current_value' => 32,
+ 'updated_value' => 30,
+ ],
+ ];
+ }
+
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ // If the first installed version is 3.4.0-*
+ // nothing to do and return
+ $firstInstalledVersion = DB::table('versions')
+ ->where('product', Application::get()->getName())
+ ->where('product_type', 'core')
+ ->orderBy('date_installed')
+ ->first();
+
+ if ($firstInstalledVersion->major == 3 && $firstInstalledVersion->minor == 4) {
+ return;
+ }
+
+ // Get the current version from which is the upgrading is happening
+ $currentVersion = DB::table('versions')
+ ->where('product', Application::get()->getName())
+ ->where('product_type', 'core')
+ ->where('current', 1)
+ ->first();
+
+ // If NOT upgrading from 3.4.0-*, then fixed migration \APP\migration\upgrade\v3_4_0\I7725_DecisionConstantsUpdate
+ // have the new fix in place and rest of the code does not need to execute
+ if ($currentVersion->major == 3 && $currentVersion->minor != 4) {
+ return;
+ }
+
+ // Upgrading from a 3.4.0-*
+ // Need to figure out the first installed date of 3.4.0-*
+ // Then need to update the decisions made before the first version of 3.4.0-* installed
+ $firstVersionOf34 = DB::table('versions')
+ ->where('product', Application::get()->getName())
+ ->where('product_type', 'core')
+ ->where('major', 3)
+ ->where('minor', 4)
+ ->orderBy('date_installed')
+ ->first();
+
+ $this->configureUpdatedAtColumn();
+
+ collect($this->getDecisionMappings())
+ ->each(
+ fn ($decisionMapping) => DB::table('edit_decisions')
+ ->when(
+ isset($decisionMapping['stage_id']) && !empty($decisionMapping['stage_id']),
+ fn ($query) => $query->whereIn('stage_id', $decisionMapping['stage_id'])
+ )
+ ->where('decision', $decisionMapping['current_value'])
+ ->whereNull('updated_at')
+ ->where('date_decided', '<', $firstVersionOf34->date_installed)
+ ->update([
+ 'decision' => $decisionMapping['updated_value'],
+ 'updated_at' => Carbon::now(),
+ ])
+ );
+
+ $this->removeUpdatedAtColumn();
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ throw new DowngradeNotSupportedException();
+ }
+}
diff --git a/classes/migration/upgrade/v3_4_0/I7725_DecisionConstantsUpdate.php b/classes/migration/upgrade/v3_4_0/I7725_DecisionConstantsUpdate.php
index 800333298b3..84e4c2494db 100644
--- a/classes/migration/upgrade/v3_4_0/I7725_DecisionConstantsUpdate.php
+++ b/classes/migration/upgrade/v3_4_0/I7725_DecisionConstantsUpdate.php
@@ -24,181 +24,38 @@ class I7725_DecisionConstantsUpdate extends \PKP\migration\upgrade\v3_4_0\I7725_
*/
public function getDecisionMappings(): array
{
+ // stage_id filtering removed: all old OMP 3.3 decision values (after I7265
+ // stage-splitting) are unique, and the parent class's updated_at tracking
+ // mechanism prevents collisions between sequential mappings (e.g., 15→13
+ // then 13→11). OMP 3.3 had no validation on which decisions could be
+ // recorded at which stages, so decisions can exist at any stage in legacy data.
+ // See https://github.com/pkp/pkp-lib/issues/12357
return [
- // \PKP\decision\Decision::INITIAL_DECLINE
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION],
- 'current_value' => 9,
- 'updated_value' => 8,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_ACCEPT
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 11,
- 'updated_value' => 9,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_PENDING_REVISIONS
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 12,
- 'updated_value' => 10,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_RESUBMIT
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 13,
- 'updated_value' => 11,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_DECLINE
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 14,
- 'updated_value' => 12,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_EXTERNAL_REVIEW
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 15,
- 'updated_value' => 13,
- ],
-
- // \PKP\decision\Decision::NEW_EXTERNAL_ROUND
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 16,
- 'updated_value' => 14,
- ],
-
- // \PKP\decision\Decision::REVERT_DECLINE
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 17,
- 'updated_value' => 15,
- ],
-
- // \PKP\decision\Decision::REVERT_INITIAL_DECLINE
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION],
- 'current_value' => 18,
- 'updated_value' => 16,
- ],
-
- // \PKP\decision\Decision::SKIP_EXTERNAL_REVIEW
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EDITING],
- 'current_value' => 19,
- 'updated_value' => 17,
- ],
-
- // \PKP\decision\Decision::SKIP_INTERNAL_REVIEW
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 20,
- 'updated_value' => 18,
- ],
-
- // \PKP\decision\Decision::ACCEPT_INTERNAL
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EDITING],
- 'current_value' => 21,
- 'updated_value' => 19,
- ],
-
- // \PKP\decision\Decision::PENDING_REVISIONS_INTERNAL
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 22,
- 'updated_value' => 20
- ],
-
- // \PKP\decision\Decision::RESUBMIT_INTERNAL
- [
- 'stage_id' => [],
- 'current_value' => 23,
- 'updated_value' => 21,
- ],
-
- // \PKP\decision\Decision::DECLINE_INTERNAL
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 24,
- 'updated_value' => 22,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_ACCEPT_INTERNAL
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 25,
- 'updated_value' => 23,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_PENDING_REVISIONS_INTERNAL
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 26,
- 'updated_value' => 24,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_RESUBMIT_INTERNAL
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 27,
- 'updated_value' => 25,
- ],
-
- // \PKP\decision\Decision::RECOMMEND_DECLINE_INTERNAL
- [
- 'stage_id' => [],
- 'current_value' => 28,
- 'updated_value' => 26,
- ],
-
- // \PKP\decision\Decision::REVERT_INTERNAL_DECLINE
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 29,
- 'updated_value' => 27,
- ],
-
- // \PKP\decision\Decision::NEW_INTERNAL_ROUND
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 30,
- 'updated_value' => 28,
- ],
-
- // \PKP\decision\Decision::BACK_FROM_PRODUCTION
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_EDITING],
- 'current_value' => 31,
- 'updated_value' => 29,
- ],
-
- // \PKP\decision\Decision::BACK_FROM_COPYEDITING
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION, WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 32,
- 'updated_value' => 30,
- ],
-
- // \PKP\decision\Decision::CANCEL_REVIEW_ROUND
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION, WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
- 'current_value' => 33,
- 'updated_value' => 31,
- ],
-
- // \PKP\decision\Decision::CANCEL_INTERNAL_REVIEW_ROUND
- [
- 'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION, WORKFLOW_STAGE_ID_INTERNAL_REVIEW],
- 'current_value' => 34,
- 'updated_value' => 32,
- ],
+ ['current_value' => 9, 'updated_value' => 8], // INITIAL_DECLINE
+ ['current_value' => 11, 'updated_value' => 9], // RECOMMEND_ACCEPT
+ ['current_value' => 12, 'updated_value' => 10], // RECOMMEND_PENDING_REVISIONS
+ ['current_value' => 13, 'updated_value' => 11], // RECOMMEND_RESUBMIT
+ ['current_value' => 14, 'updated_value' => 12], // RECOMMEND_DECLINE
+ ['current_value' => 15, 'updated_value' => 13], // RECOMMEND_EXTERNAL_REVIEW
+ ['current_value' => 16, 'updated_value' => 14], // NEW_EXTERNAL_ROUND
+ ['current_value' => 17, 'updated_value' => 15], // REVERT_DECLINE
+ ['current_value' => 18, 'updated_value' => 16], // REVERT_INITIAL_DECLINE
+ ['current_value' => 19, 'updated_value' => 17], // SKIP_EXTERNAL_REVIEW
+ ['current_value' => 20, 'updated_value' => 18], // SKIP_INTERNAL_REVIEW
+ ['current_value' => 21, 'updated_value' => 19], // ACCEPT_INTERNAL
+ ['current_value' => 22, 'updated_value' => 20], // PENDING_REVISIONS_INTERNAL
+ ['current_value' => 23, 'updated_value' => 21], // RESUBMIT_INTERNAL
+ ['current_value' => 24, 'updated_value' => 22], // DECLINE_INTERNAL
+ ['current_value' => 25, 'updated_value' => 23], // RECOMMEND_ACCEPT_INTERNAL
+ ['current_value' => 26, 'updated_value' => 24], // RECOMMEND_PENDING_REVISIONS_INTERNAL
+ ['current_value' => 27, 'updated_value' => 25], // RECOMMEND_RESUBMIT_INTERNAL
+ ['current_value' => 28, 'updated_value' => 26], // RECOMMEND_DECLINE_INTERNAL
+ ['current_value' => 29, 'updated_value' => 27], // REVERT_INTERNAL_DECLINE
+ ['current_value' => 30, 'updated_value' => 28], // NEW_INTERNAL_ROUND
+ ['current_value' => 31, 'updated_value' => 29], // BACK_FROM_PRODUCTION
+ ['current_value' => 32, 'updated_value' => 30], // BACK_FROM_COPYEDITING
+ ['current_value' => 33, 'updated_value' => 31], // CANCEL_REVIEW_ROUND
+ ['current_value' => 34, 'updated_value' => 32], // CANCEL_INTERNAL_REVIEW_ROUND
];
}
}
diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml
index 5ce7ce8c93e..27d352721df 100644
--- a/dbscripts/xml/upgrade.xml
+++ b/dbscripts/xml/upgrade.xml
@@ -211,6 +211,11 @@
+
+
+
+
+