Commit 733beb94 authored by catch's avatar catch
Browse files

Issue #3116216 by Gábor Hojtsy, quietone, heddn: Remove deprecated MigrateState legacy procedure

parent 77943a2d
......@@ -155,21 +155,6 @@ class MigrationState {
*/
protected $fieldPluginManager;
/**
* Source modules that will not be migrated determined using legacy method.
*
* @var array
*/
protected $unmigratedSourceModules = [];
/**
* Source modules that will be migrated determined using legacy method, keyed
* by version.
*
* @var array
*/
protected $migratedSourceModules = [];
/**
* An array of migration states declared for each source migration.
*
......@@ -323,25 +308,6 @@ protected function buildUpgradeState($version, array $source_system_data, array
// source_modules are enabled so do the same here.
if ($module['status']) {
$source_module = $module['name'];
// If there is not a declared state for this source module then use the
// legacy method for determining the migration state.
if (!isset($this->stateBySource[$version][$source_module])) {
// No migrations found for this source module.
if (!empty($this->unmigratedSourceModules[$version]) && array_key_exists($source_module, $this->unmigratedSourceModules[$version])) {
$upgrade_state[static::NOT_FINISHED][$source_module] = '';
continue;
}
if (!empty($this->migratedSourceModules[$version]) && array_key_exists($source_module, $this->migratedSourceModules[$version])) {
@trigger_error(sprintf("Using migration plugin definitions to determine the migration state of the module '%s' is deprecated in Drupal 8.7. Add the module to a migrate_drupal.yml file. See https://www.drupal.org/node/2929443", $source_module), E_USER_DEPRECATED);
if (array_diff(array_keys($this->migratedSourceModules[$version][$source_module]), $this->enabledModules)) {
$upgrade_state[static::NOT_FINISHED][$source_module] = implode(', ', array_keys($this->migratedSourceModules[$version][$source_module]));
continue;
}
$upgrade_state[static::FINISHED][$source_module] = implode(', ', array_keys($this->migratedSourceModules[$version][$source_module]));
}
continue;
}
$upgrade_state[$this->getSourceState($version, $source_module)][$source_module] = implode(', ', $this->getDestinationsForSource($version, $source_module));
}
......@@ -401,13 +367,6 @@ protected function buildDiscoveredDestinationsBySource($version, array $migratio
foreach ($table_data as $source_module => $destination_module_info) {
ksort($table_data[$source_module]);
}
$tmp = array_diff_key($source_system_data['module'], $table_data);
foreach ($tmp as $source_module => $module_data) {
if ($module_data['status']) {
$this->unmigratedSourceModules[$version][$source_module] = $module_data;
}
}
$this->migratedSourceModules[$version] = $table_data;
$this->discoveredBySource[$version] = array_map('array_unique', $discovered_upgrade_paths);
}
......@@ -458,6 +417,10 @@ protected function getSourceState($version, $source_module) {
// No discovered or declared state.
return MigrationState::NOT_FINISHED;
}
if (!isset($this->stateBySource[$version][$source_module])) {
// No declared state.
return MigrationState::NOT_FINISHED;
}
if (in_array(MigrationState::NOT_FINISHED, $this->stateBySource[$version][$source_module], TRUE) || !in_array(MigrationState::FINISHED, $this->stateBySource[$version][$source_module], TRUE)) {
return MigrationState::NOT_FINISHED;
}
......
name: Migrate state no migrate_drupal.yml file test
type: module
description: Has a migration but Does not have a migrate_drupal.yml file.
package: Testing
version: VERSION
id: migrate_state_no_file_test
label: Test
migration_tags:
- Drupal 6
- Drupal 7
- Configuration
source:
plugin: embedded_data
data_rows:
-
id: 1
ids:
id:
type: string
source_module: migrate_state_no_file_test
process: []
destination:
plugin: entity:field_config
destination_module: migrate_state_no_file_test
<?php
namespace Drupal\Tests\migrate_drupal\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Defines a class for testing deprecation error from MigrationState.
*
* @group migrate_drupal
* @group legacy
*/
class MigrationStateDeprecationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'migrate_drupal',
'migrate',
'migrate_state_no_file_test',
];
/**
* Tests migration state deprecation notice.
*
* Test that a module with a migration but without a .migrate_drupal.yml
* trigger deprecation errors.
*
* @doesNotPerformAssertions
* @expectedDeprecation Using migration plugin definitions to determine the migration state of the module 'migrate_state_no_file_test' is deprecated in Drupal 8.7. Add the module to a migrate_drupal.yml file. See https://www.drupal.org/node/2929443
*/
public function testUndeclaredDestinationDeprecation() {
$plugin_manager = \Drupal::service('plugin.manager.migration');
$all_migrations = $plugin_manager->createInstancesByTag('Drupal 7');
\Drupal::service('migrate_drupal.migration_state')
->getUpgradeStates(7, [
'module' => [
'migrate_state_no_file_test' => [
'name' => 'migrate_state_no_file_test',
'status' => TRUE,
],
],
], ['import' => $all_migrations['migrate_state_no_file_test']]);
}
}
......@@ -28,8 +28,6 @@ class StateFileExists extends MigrateDrupalTestBase {
// Test migrations states.
'migrate_state_finished_test',
'migrate_state_not_finished_test',
// Test missing migrate_drupal.yml.
'migrate_state_no_file_test',
];
/**
......
......@@ -258,11 +258,12 @@ public function providerGetUpgradeStates() {
'search' => '',
// Declared finished by one module but not finished by another.
'user' => 'user',
// Enabled and not declared.
'rdf' => 'rdf',
'link' => 'link',
],
MigrationState::FINISHED => [
'link' => 'link',
'node' => 'node',
'rdf' => 'rdf',
],
],
'expected_6' => [
......@@ -279,12 +280,11 @@ public function providerGetUpgradeStates() {
// No discovered or declared state.
'search' => '',
'color' => '',
'link' => 'link',
],
MigrationState::FINISHED => [
'node' => 'node',
'content' => 'node',
// Update path not needed.
'link' => 'link',
],
],
];
......
......@@ -37,8 +37,6 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
'migrate_state_finished_test',
'migrate_state_not_finished_test',
// Test missing migrate_drupal.yml.
'migrate_state_no_file_test',
// Test missing migrate_drupal.yml.
'migrate_state_no_upgrade_path',
];
......
......@@ -33,8 +33,6 @@ class NoMultilingualReviewPageTest extends NoMultilingualReviewPageTestBase {
// Test migrations states.
'migrate_state_finished_test',
'migrate_state_not_finished_test',
// Test missing migrate_drupal.yml.
'migrate_state_no_file_test',
];
/**
......
......@@ -35,8 +35,6 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
// Test migrations states.
'migrate_state_finished_test',
'migrate_state_not_finished_test',
// Test missing migrate_drupal.yml.
'migrate_state_no_file_test',
];
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment