diff -u b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php --- b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php @@ -8,7 +8,7 @@ use Drupal\migrate\Row; /** - * Master destination for migrating the entire entity revision table. + * Provides a node destination for migrating the entire entity revision table. * * @MigrateDestination( * id = "entity_master", @@ -63,7 +63,7 @@ $entity->setNewRevision(TRUE); } else { - // Attempt to ensure we always have a bundle. + // Attempt to set the bundle. if ($bundle = $this->getBundle($row)) { $row->setDestinationProperty($this->getKey('bundle'), $bundle); } diff -u b/core/modules/migrate_drupal/src/NodeMigrateType.php b/core/modules/migrate_drupal/src/NodeMigrateType.php --- b/core/modules/migrate_drupal/src/NodeMigrateType.php +++ b/core/modules/migrate_drupal/src/NodeMigrateType.php @@ -7,6 +7,8 @@ */ final class NodeMigrateType { + use MigrationConfigurationTrait; + /** * Only the master node migration map tables are in use. */ @@ -42,8 +44,7 @@ * @internal * Only to be used by migrate_drupal_migration_plugins_alter(). */ - public static function getNodeMigrateType(array $definitions) { - $migrate_type = static::NODE_MIGRATE_TYPE_MASTER; + public function getNodeMigrateType(array $definitions) { $version = ''; // We need to get the version of the source database in order to check @@ -67,31 +68,24 @@ $version_string = FALSE; if ($connection) { - // Determine the source database version. This is an excerpt from - // getLegacyDrupalVersion for Drupal 5, 6 or 7 source databases. - // See \Drupal\migrate_drupal\MigrationConfigurationTrait::getLegacyDrupalVersion - 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; - } - } + $version = $this->getLegacyDrupalVersion($connection); } - $version = $version_string ? substr($version_string, 0, 1) : FALSE; } + return $this->migrateType($version); + } + + /** + * Helper to determine what node migrate map tables have data. + * + * @param string $version + * The Drupal version of the source database. + * + * @return string + * The migrate type. + */ + protected function migrateType($version) { + $migrate_type = static::NODE_MIGRATE_TYPE_MASTER; if ($version) { $node_has_rows = FALSE; $node_master_has_rows = FALSE; @@ -135,10 +129,12 @@ } // This might be a test environment. - if (\Drupal::service('module_handler')->moduleExists('node_migrate_classic')) { + if (\Drupal::service('module_handler') + ->moduleExists('node_migrate_classic')) { $migrate_type = NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC; } - if (\Drupal::service('module_handler')->moduleExists('node_migrate_master')) { + if (\Drupal::service('module_handler') + ->moduleExists('node_migrate_master')) { $migrate_type = NodeMigrateType::NODE_MIGRATE_TYPE_MASTER; } return $migrate_type; diff -u b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeMasterTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeMasterTest.php --- b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeMasterTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeMasterTest.php @@ -60,9 +60,6 @@ * Tests the master node migration. */ public function testNodeMasterMigration() { - $migration = \Drupal::service('plugin.manager.migration')->createInstances('d6_node_master'); - $result = (new IdAuditor())->auditMultiple($migration); - $db = \Drupal::database(); $this->assertEquals($this->expectedNodeFieldRevisionTable(), $db->select('node_field_revision', 'nr') ->fields('nr') diff -u b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeMasterTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeMasterTest.php --- b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeMasterTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeMasterTest.php @@ -102,10 +102,11 @@ ->execute() ->fetchAll(\PDO::FETCH_ASSOC)); - // Now load and test each revision, including the field 'field_text_long_plain' - // which has text reflecting the revision. - // Source node 1. This node uses entity translation which does not have a - // migrate. See https://www.drupal.org/project/drupal/issues/3076447. + // Now load and test each revision, + // including the field 'field_text_long_plain' which has text reflecting the + // revision. Note that source node 1, uses entity translation which does + // not have a migration for revisions of translations. + // See https://www.drupal.org/project/drupal/issues/3076447. $data = $this->expectedRevisionEntityData()[0]; foreach ($this->expectedNodeFieldRevisionTable() as $key => $revision) { $this->assertRevision($revision, $data[$key]);