Skip to content

Commit

Permalink
Issue #3133305 by quietone, daffie, xjm, benjifisher, longwave: Use \…
Browse files Browse the repository at this point in the history
…Drupal::VERSION to get the version in Migrate UI rather than hardcoding it

(cherry picked from commit 4d49b8499162b989cfbdd9b7b2098e4016d222f7)
  • Loading branch information
xjm committed May 11, 2020
1 parent 8654d1c commit 00af64c
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 17 deletions.
5 changes: 4 additions & 1 deletion modules/migrate_drupal_ui/src/Form/IdConflictForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ protected function conflictsForm(array &$form, array $conflicts) {

$form['warning'] = [
'#type' => 'markup',
'#markup' => '<p>' . $this->t('It looks like you have content on your new site which <strong>may be overwritten</strong> if you continue to run this upgrade. The upgrade should be performed on a clean Drupal 8 installation. For more information see the <a target="_blank" href=":id-conflicts-handbook">upgrade handbook</a>.', [':id-conflicts-handbook' => 'https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#id_conflicts']) . '</p>',
'#markup' => '<p>' . $this->t('It looks like you have content on your new site which <strong>may be overwritten</strong> if you continue to run this upgrade. The upgrade should be performed on a clean Drupal @version installation. For more information see the <a target="_blank" href=":id-conflicts-handbook">upgrade handbook</a>.', [
'@version' => $this->destinationSiteVersion,
':id-conflicts-handbook' => 'https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#id_conflicts',
]) . '</p>',
];

return $form;
Expand Down
5 changes: 4 additions & 1 deletion modules/migrate_drupal_ui/src/Form/IncrementalForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// https://www.drupal.org/node/2687849
$form['upgrade_option_item'] = [
'#type' => 'item',
'#prefix' => $this->t('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal 8. Rollbacks are not yet supported through the user interface. For more information, see the <a href=":url">upgrading handbook</a>.', [':url' => 'https://www.drupal.org/upgrade/migrate']),
'#prefix' => $this->t('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal @version. Rollbacks are not yet supported through the user interface. For more information, see the <a href=":url">upgrading handbook</a>.', [
'@version' => $this->destinationSiteVersion,
':url' => 'https://www.drupal.org/upgrade/migrate',
]),
'#description' => $this->t('Last upgrade: @date', ['@date' => $this->dateFormatter->format($date_performed)]),
];
return $form;
Expand Down
9 changes: 9 additions & 0 deletions modules/migrate_drupal_ui/src/Form/MigrateUpgradeFormBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ abstract class MigrateUpgradeFormBase extends FormBase {
*/
protected $store;

/**
* The destination site major version.
*
* @var string
*/
protected $destinationSiteVersion;

/**
* Constructs the Migrate Upgrade Form Base.
*
Expand Down Expand Up @@ -60,6 +67,8 @@ public static function create(ContainerInterface $container) {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// Get the current major version.
list($this->destinationSiteVersion) = explode('.', \Drupal::VERSION, 2);
$form = [];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
Expand Down
5 changes: 3 additions & 2 deletions modules/migrate_drupal_ui/src/Form/OverviewForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['#title'] = $this->t('Upgrade');

$form['info_header'] = [
'#markup' => '<p>' . $this->t('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8. See the <a href=":url">Drupal site upgrades handbook</a> for more information.', [
'#markup' => '<p>' . $this->t('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal @version. See the <a href=":url">Drupal site upgrades handbook</a> for more information.', [
'@version' => $this->destinationSiteVersion,
':url' => 'https://www.drupal.org/upgrade/migrate',
]),
];
Expand All @@ -45,7 +46,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['legend']['#markup'] .= '<dt>' . $this->t('Old site') . '</dt>';
$form['legend']['#markup'] .= '<dd>' . $this->t('The site you want to upgrade.') . '</dd>';
$form['legend']['#markup'] .= '<dt>' . $this->t('New site') . '</dt>';
$form['legend']['#markup'] .= '<dd>' . $this->t('This empty Drupal 8 installation you will import the old site to.') . '</dd>';
$form['legend']['#markup'] .= '<dd>' . $this->t('This empty Drupal @version installation you will import the old site to.', ['@version' => $this->destinationSiteVersion]) . '</dd>';
$form['legend']['#markup'] .= '</dl>';

$info[] = $this->t('Make sure that <strong>access to the database</strong> for the old site is available from this new site.');
Expand Down
4 changes: 2 additions & 2 deletions modules/migrate_drupal_ui/src/Form/ReviewForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'table',
'#header' => [
$this->t('Drupal @version', ['@version' => $version]),
$this->t('Drupal 8'),
$this->t('Drupal @version', ['@version' => $this->destinationSiteVersion]),
],
];

Expand Down Expand Up @@ -161,7 +161,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'table',
'#header' => [
$this->t('Drupal @version', ['@version' => $version]),
$this->t('Drupal 8'),
$this->t('Drupal @version', ['@version' => $this->destinationSiteVersion]),
],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ abstract class MigrateUpgradeExecuteTestBase extends MigrateUpgradeTestBase {

use CreateTestContentEntitiesTrait;

/**
* The destination site major version.
*
* @var string
*/
protected $destinationSiteVersion;

/**
* {@inheritdoc}
*/
Expand All @@ -19,6 +26,9 @@ protected function setUp() {

// Create content.
$this->createContent();

// Get the current major version.
[$this->destinationSiteVersion] = explode('.', \Drupal::VERSION, 2);
}

/**
Expand All @@ -34,7 +44,7 @@ public function testMigrateUpgradeExecute() {
$connection_options = $this->sourceDatabase->getConnectionOptions();
$this->drupalGet('/upgrade');
$session = $this->assertSession();
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down Expand Up @@ -99,7 +109,7 @@ public function testMigrateUpgradeExecute() {

// Restart the upgrade process.
$this->drupalGet('/upgrade');
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down Expand Up @@ -140,7 +150,7 @@ public function testMigrateUpgradeExecute() {
$this->createContentPostUpgrade();

$this->drupalGet('/upgrade');
$session->pageTextContains('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal 8. Rollbacks are not yet supported through the user interface.');
$session->pageTextContains("An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal $this->destinationSiteVersion. Rollbacks are not yet supported through the user interface.");
$this->drupalPostForm(NULL, [], t('Import new configuration and content from old site'));
$this->drupalPostForm(NULL, $edits, t('Review upgrade'));
$session->pageTextContains('WARNING: Content may be overwritten on your new site.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public function testMigrateUpgradeReviewPage() {
// Overview form and for an incremental migration it is the Incremental
// form.
$session = $this->assertSession();
$expected['initial'] = 'Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.';
// Get the current major version.
list($destination_site_version) = explode('.', \Drupal::VERSION, 2);
$expected['initial'] = "Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $destination_site_version.";
$expected['incremental'] = "An upgrade has already been performed on this site.";

foreach (['/upgrade', '/upgrade/incremental'] as $expected) {
Expand Down Expand Up @@ -113,7 +115,7 @@ public function testMigrateUpgradeReviewPage() {
// Test that the credential form is displayed for incremental migrations.
$store->set('step', 'overview');
$this->drupalGet('/upgrade');
$session->pageTextContains('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal 8. Rollbacks are not yet supported through the user interface.');
$session->pageTextContains("An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal $destination_site_version. Rollbacks are not yet supported through the user interface.");
$this->drupalPostForm(NULL, [], t('Import new configuration and content from old site'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testMigrateUpgradeExecute() {
$connection_options = $this->sourceDatabase->getConnectionOptions();
$this->drupalGet('/upgrade');
$session = $this->assertSession();
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down Expand Up @@ -102,7 +102,7 @@ public function testMigrateUpgradeExecute() {

// Start the upgrade process.
$this->drupalGet('/upgrade');
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testMigrateUpgradeExecute() {
$connection_options = $this->sourceDatabase->getConnectionOptions();
$this->drupalGet('/upgrade');
$session = $this->assertSession();
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down Expand Up @@ -112,7 +112,7 @@ public function testMigrateUpgradeExecute() {

// Start the upgrade process.
$this->drupalGet('/upgrade');
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testMigrateUpgradeExecute() {
$connection_options = $this->sourceDatabase->getConnectionOptions();
$this->drupalGet('/upgrade');
$session = $this->assertSession();
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down Expand Up @@ -104,7 +104,7 @@ public function testMigrateUpgradeExecute() {

// Start the upgrade process.
$this->drupalGet('/upgrade');
$session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
$session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

$this->drupalPostForm(NULL, [], t('Continue'));
$session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
Expand Down

0 comments on commit 00af64c

Please sign in to comment.