diff -u b/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module --- b/core/modules/migrate_drupal/migrate_drupal.module +++ b/core/modules/migrate_drupal/migrate_drupal.module @@ -94,80 +94,2 @@ } - - $revision_translations = TRUE; - if ($revision_translations) { - $version = migrate_drupal_isMultilingualSource($definitions); - if ($version) { - $patterns = '/(d' . $version . '_node:)|(d' . $version . '_node_translation:)|(d' . $version . '_node_revision:)/'; - - foreach ($definitions as $key => &$definition) { - if (preg_match($patterns, $key)) { - unset($definitions[$key]); - } - } - } - } -} - -/** - * @return bool - */ -function migrate_drupal_isMultilingualSource($definitions) { - $source_plugin = \Drupal::service('plugin.manager.migration') - ->createStubMigration($definitions['system_site']) - ->getSourcePlugin(); - $connection = NULL; - - try { - $connection = $source_plugin->getDatabase(); - } - catch (RequirementsException $e) { - // It is possible the commerce_migrate is enabled to use the supplied - // plugins, but the migrations are not configured. In this case, the - // exported configurations are not available to swap out the default - // sql source key of 'migrate'. - } - if ($connection) { - // Get the Drupal version of the source database so it can be validated. - $version = (string) migrate_drupal_getLegacyDrupalVersion($connection); - $i18nTable = ($version === '6') ? 'i18nstring' : 'i18n_string'; - if ($connection->schema()->tableExists($i18nTable)) { - return $version; - } - } -} - -/** - * Determines what version of Drupal the source database contains. - * - * @param \Drupal\Core\Database\Connection $connection - * The database connection object. - * - * @return string|false - * A string representing the major branch of Drupal core (e.g. '6' for - * Drupal 6.x), or FALSE if no valid version is matched. - */ -function migrate_drupal_getLegacyDrupalVersion(Connection $connection) { - // Don't assume because a table of that name exists, that it has the columns - // we're querying. Catch exceptions and report that the source database is - // not Drupal. - // Drupal 5/6/7 can be detected by the schema_version in the system table. - if ($connection->schema()->tableExists('system')) { - try { - $version_string = $connection - ->query('SELECT schema_version FROM {system} WHERE name = :module', [':module' => 'system']) - ->fetchField(); - if ($version_string && $version_string[0] == '1') { - if ((int) $version_string >= 1000) { - $version_string = '5'; - } - else { - $version_string = FALSE; - } - } - } - catch (\PDOException $e) { - $version_string = FALSE; - } - } - return $version_string ? substr($version_string, 0, 1) : FALSE; } only in patch2: unchanged: --- a/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php +++ b/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php @@ -102,6 +102,16 @@ protected function getMigrations($database_state_key, $drupal_version) { $plugin_manager = \Drupal::service('plugin.manager.migration'); /** @var \Drupal\migrate\Plugin\Migration[] $all_migrations */ $all_migrations = $plugin_manager->createInstancesByTag($version_tag); + + if ($this->isMultilingualSource($database_state_key, $drupal_version)) { + $patterns = '/(d' . $drupal_version . '_node:)|(d' . $drupal_version . '_node_translation:)|(d' . $drupal_version . '_node_revision:)/'; + foreach ($all_migrations as $key => $migrations) { + if (preg_match($patterns, $key)) { + unset($all_migrations[$key]); + } + } + } + $migrations = []; foreach ($all_migrations as $migration) { // Skip migrations tagged with any of the follow-up migration tags. They @@ -210,4 +220,23 @@ protected function getLegacyDrupalVersion(Connection $connection) { return $version_string ? substr($version_string, 0, 1) : FALSE; } + /** + * Determines if the source database is multilingual. + * + * @return bool + * The version if this is a source database with i18n, FALSE otherwise. + */ + protected function isMultilingualSource($database_state_key, $version) { + $database_state = \Drupal::state()->get($database_state_key); + // Connect to source database. + $connection = $this->getConnection($database_state['database']); + if ($connection) { + $i18nTable = ($version === '6') ? 'i18nstring' : 'i18n_string'; + if ($connection->schema()->tableExists($i18nTable)) { + return TRUE; + } + } + return FALSE; + } + }