Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/main/7599 remove submission stage #215

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,56 @@
<?php

/**
* @file classes/migration/upgrade/3_4_0/I7599_UpdateInvalidStageId.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I7599_UpdateInvalidStageId
* @brief Ensure there's no data assigned to the submission stage in order to address the issue pkp/pkp-lib#7599.
*/

namespace APP\migration\upgrade\v3_4_0;

use Exception;
use Illuminate\Support\Facades\DB;
use PKP\install\DowngradeNotSupportedException;

class I7599_UpdateInvalidStageId extends \PKP\migration\Migration
{
/**
* Run the migration.
*/
public function up(): void
{
// Ensure there's no data assigned to tables which would be risky to update by ourselves
$riskyTables = array_filter(
['review_round_files', 'review_assignments', 'edit_decisions', 'review_rounds'],
fn ($table) => DB::table($table)->where('stage_id', '<>', '5')->count() > 0
);
if (count($riskyTables)) {
throw new Exception(
'The upgrade is unable to proceed safely due to the existence of records using a'
. ' non-production stage (all records should have stage_id = 5) in the following'
. ' tables (the records must be updated/merged/removed manually before attempting to upgrade again): '
. implode(', ', $riskyTables)
);
}

// Update any stage to WORKFLOW_STAGE_ID_PRODUCTION
DB::statement('UPDATE submissions SET stage_id = 5 WHERE stage_id <> 5');
DB::statement('UPDATE queries SET stage_id = 5 WHERE stage_id <> 5');
// Remove records which don't have the stage_id equals to WORKFLOW_STAGE_ID_PRODUCTION
DB::statement('DELETE FROM email_templates_default WHERE stage_id <> 5');
DB::statement('DELETE FROM user_group_stage WHERE stage_id <> 5');
}

/**
* Reverse the downgrades
*/
public function down(): void
{
throw new DowngradeNotSupportedException();
}
}
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Expand Up @@ -42,6 +42,7 @@
<migration class="PKP\migration\upgrade\v3_4_0\I7167_RemoveDuplicatedUserSettingsAndDeprecatedFields" />
<migration class="APP\migration\upgrade\v3_4_0\I7264_UpdateEmailTemplates"/>
<migration class="APP\migration\upgrade\v3_4_0\I7014_DoiMigration"/>
<migration class="APP\migration\upgrade\v3_4_0\I7599_UpdateInvalidStageId"/>
<data file="dbscripts/xml/upgrade/3.4.0_preupdate_email_templates.xml" />
<note file="docs/release-notes/README-3.4.0" />
</upgrade>
Expand Down
6 changes: 3 additions & 3 deletions registry/userGroups.xml
Expand Up @@ -14,13 +14,13 @@

<groups>
<!-- Managerial Role -->
<group roleId="0x00000010" stages="1,5" name="default.groups.name.manager" plural="default.groups.plural.manager" abbrev="default.groups.abbrev.manager" permitMetadataEdit="true" />
<group roleId="0x00000010" stages="5" name="default.groups.name.manager" plural="default.groups.plural.manager" abbrev="default.groups.abbrev.manager" permitMetadataEdit="true" />

<!-- Moderator Role -->
<group roleId="0x00000011" stages="1,5" name="default.groups.name.sectionEditor" plural="default.groups.plural.sectionEditor" abbrev="default.groups.abbrev.sectionEditor" permitMetadataEdit="true" />
<group roleId="0x00000011" stages="5" name="default.groups.name.sectionEditor" plural="default.groups.plural.sectionEditor" abbrev="default.groups.abbrev.sectionEditor" permitMetadataEdit="true" />

<!-- Author Role -->
<group roleId="0x00010000" stages="1,5" name="default.groups.name.author" plural="default.groups.plural.author" abbrev="default.groups.abbrev.author" permitSelfRegistration="true" permitMetadataEdit="true" />
<group roleId="0x00010000" stages="5" name="default.groups.name.author" plural="default.groups.plural.author" abbrev="default.groups.abbrev.author" permitSelfRegistration="true" permitMetadataEdit="true" />

<!-- Reader Role -->
<group roleId="0x00100000" stages="" name="default.groups.name.reader" plural="default.groups.plural.reader" abbrev="default.groups.abbrev.reader" permitSelfRegistration="true" />
Expand Down