Skip to content

Commit

Permalink
pkp#10571 Move migration into v3.6 folder
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham committed Dec 19, 2024
1 parent f05ff90 commit 01000e1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 16 deletions.
14 changes: 0 additions & 14 deletions classes/emailTemplate/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,6 @@ protected function mapByProperties(array $props, EmailTemplate $item, string $ma
$output = [];

$mailableClass = $mailableClass ?? Repo::mailable()->getMailableByEmailTemplate($item);
$assignedUserGroupsIds = [];
// some mailable are not found during some operations such as performing a search for templates. So ensure mailable exist before using
// if ($mailableClass) {
// $isUserGroupsAssignable = Repo::mailable()->isGroupsAssignableToTemplates($mailableClass);
// $assignedUserGroupsIds = Repo::emailTemplate()->getUserGroupsIdsAssignedToTemplate($item->getData('key'), Application::get()->getRequest()->getContext()->getId());
// if (!$isUserGroupsAssignable) {
// $output['assignedUserGroupIds'] = [];
// } else {
// // Get the current user groups assigned to the template
// $output['assignedUserGroupIds'] = $assignedUserGroupsIds;
// }
// }


foreach ($props as $prop) {
switch ($prop) {
case '_href':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace PKP\migration\upgrade\v3_5_0;
namespace PKP\migration\upgrade\V3_6_0;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
Expand All @@ -9,7 +9,7 @@
use PKP\emailTemplate\EmailTemplateAccessGroup;
use PKP\migration\Migration;

class I10403_EmailTemplateUserGroupAccess extends Migration
class I10403_g extends Migration
{
/**
* Run the migrations.
Expand Down
62 changes: 62 additions & 0 deletions classes/migration/upgrade/V3_6_0/PreflightCheckMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/PreflightCheckMigration.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 PreflightCheckMigration
*
* @brief Check for common problems early in the upgrade process.
*/

namespace PKP\migration\upgrade\V3_6_0;

use PKP\db\DAORegistry;
use Throwable;

class PreflightCheckMigration extends \PKP\migration\Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
try {
} catch (Throwable $e) {
if ($fallbackVersion = $this->setFallbackVersion()) {
$this->_installer->log("A pre-flight check failed. The software was successfully upgraded to {$fallbackVersion} but could not be upgraded further (to " . $this->_installer->newVersion->getVersionString() . '). Check and correct the error, then try again.');
}
throw $e;
}
}

/**
* Rollback the migrations.
*/
public function down(): void
{
if ($fallbackVersion = $this->setFallbackVersion()) {
$this->_installer->log("An upgrade step failed! Fallback set to {$fallbackVersion}. Check and correct the error and try the upgrade again. We recommend restoring from backup, though you may be able to continue without doing so.");
// Prevent further downgrade migrations from executing.
$this->_installer->migrations = [];
}
}

/**
* Store the fallback version in the database, permitting resumption of partial upgrades.
*
* @return ?string Fallback version, if one was identified
*/
protected function setFallbackVersion(): ?string
{
if ($fallbackVersion = $this->_attributes['fallback'] ?? null) {
$versionDao = DAORegistry::getDAO('VersionDAO'); /** @var \PKP\site\VersionDAO $versionDao */
$versionDao->insertVersion(\PKP\site\Version::fromString($fallbackVersion));
return $fallbackVersion;
}
return null;
}
}

0 comments on commit 01000e1

Please sign in to comment.