only in patch2: unchanged: --- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -971,14 +971,9 @@ protected function getMigrationPluginManager() { * {@inheritdoc} */ public function getHighestId() { - array_filter( - $this->migration->getDestinationPlugin()->getIds(), - function (array $id) { - if ($id['type'] !== 'integer') { - throw new \LogicException('Cannot determine the highest migrated ID without an integer ID column'); - } - } - ); + if (array_search('integer', array_column($this->migration->getDestinationPlugin()->getIds(), 'type')) === FALSE) { + throw new \LogicException('Cannot determine the highest migrated ID without an integer ID column'); + }; // List of mapping tables to look in for the highest ID. $map_tables = [ only in patch2: unchanged: --- a/core/modules/migrate_drupal/migrate_drupal.module +++ b/core/modules/migrate_drupal/migrate_drupal.module @@ -5,6 +5,7 @@ * Provides migration from other Drupal sites. */ +use Drupal\Core\Database\Connection; use Drupal\Core\Url; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Routing\RouteMatchInterface; @@ -91,4 +92,82 @@ function migrate_drupal_migration_plugins_alter(&$definitions) { } } + + $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; }