diff -u b/core/modules/file/src/Plugin/migrate/field/d6/ImageField.php b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php --- b/core/modules/file/src/Plugin/migrate/field/d6/ImageField.php +++ b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php @@ -8,13 +8,13 @@ /** * @MigrateField( - * id = "imagefield", + * id = "filefield", * core = {6}, - * source_module = "imagefield", + * source_module = "filefield", * destination_module = "file" * ) */ -class ImageField extends FieldPluginBase { +class FileField extends FieldPluginBase { /** * {@inheritdoc} diff -u b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php --- b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php @@ -63,6 +63,9 @@ } } + /** + * Tests that modules exist for all field plugins. + */ public function testFieldProvidersExist() { $expected_mappings = [ 'userreference' => [ @@ -118,8 +121,8 @@ 'destination_module' => 'text', ], 'd7_text' => [ - 'source_module' => 'text', - 'destination_module' => 'text', + 'source_module' => 'text', + 'destination_module' => 'text', ], 'taxonomy_term_reference' => [ 'source_module' => 'taxonomy', @@ -153,12 +156,12 @@ $modules_to_enable = array_keys(array_diff_key($modules, $modules_enabled)); $this->enableModules($modules_to_enable); - /** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $plugin_manager */ + /** @var \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager $plugin_manager */ $plugin_manager = $this->container->get('plugin.manager.migrate.field'); $definitions = $plugin_manager->getDefinitions(); foreach ($definitions as $key => $definition) { - $this->assertEquals($expected_mappings[$key]['source_module'], $definition['source_module']); - $this->assertEquals($expected_mappings[$key]['destination_module'], $definition['destination_module']); + $this->assertEquals($expected_mappings[$key]['source_module'], $plugin_manager->getSourceModule($definition)); + $this->assertEquals($expected_mappings[$key]['destination_module'], $plugin_manager->getDestinationModule($definition)); unset($definitions[$key]); } // Make sure we test all the fields. diff -u b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php --- b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php @@ -18,7 +18,7 @@ * * @ingroup migration */ -class MigrateCckFieldPluginManager extends MigratePluginManager implements MigrateCckFieldPluginManagerInterface { +class MigrateCckFieldPluginManager extends MigrateFieldPluginManager implements MigrateCckFieldPluginManagerInterface { /** * The default version of core to use for cck field plugins. diff -u b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php --- b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php @@ -69,2 +69,16 @@ + /** + * {@inheritdoc} + */ + public function getSourceModule($definition) { + return isset($definition['source_module']) ? $definition['source_module'] : ''; + } + + /** + * {@inheritdoc} + */ + public function getDestinationModule($definition) { + return isset($definition['destination_module']) ? $definition['destination_module'] : ''; + } + } diff -u b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php --- b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -500,21 +500,50 @@ } } - // Now get the field migrations. - $field_types = \Drupal::service('plugin.manager.field.field_type')->getDefinitions(); - foreach ($field_types as $field_type => $value) { + // Get all the field types from the source database using the source + // plugin in the field migration. + $field_types = []; + $definition = [ + 'source' => [ + 'ignore_map' => TRUE, + 'plugin' => 'd' . "$version" . '_field', + ], + 'destination' => [ + 'plugin' => 'null', + ], + ]; + try { + $source_plugin = \Drupal::service('plugin.manager.migration') + ->createStubMigration($definition) + ->getSourcePlugin(); + $source_plugin->checkRequirements(); + + foreach ($source_plugin as $row) { + $field_types[] = $row->getSourceProperty('type'); + } + $field_types = array_unique($field_types); + } + catch (RequirementsException $e) { + // If checkRequirements() failed then the field module did not exist and + // we do not have any fields. Therefore, $field_types will be empty below. + } + + // For each field type in the source get the source_module and the + // destination_module from the relevant field plugin. + foreach ($field_types as $field_type) { try { $plugin_id = $this->fieldPluginManager->getPluginIdFromFieldType($field_type, ['core' => $version]); - $field_definition = $this->fieldPluginManager->getDefinition($plugin_id); - $field_plugin_id = $field_definition['id']; - $source_module = $field_definition['source_module']; - $destination_module = $field_definition['destination_module']; + $definition = $this->fieldPluginManager->getDefinition($plugin_id); + $source_module = $this->fieldPluginManager->getSourceModule($definition); + $destination_module = $this->fieldPluginManager->getDestinationModule($definition); if (($destination_module == 'core') || $this->moduleHandler->moduleExists($destination_module)) { - $table_data[$source_module][$destination_module][$field_plugin_id] = $field_plugin_id; + $field_plugin_id = $definition['id']; + $table_data[$source_module][$destination_module][$definition['id']] = $field_plugin_id; } } catch (PluginNotFoundException $ex) { - continue; + // If checkRequirements() failed then there is no field migration for + // this field type. } } only in patch2: unchanged: --- a/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManagerInterface.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManagerInterface.php @@ -25,4 +25,25 @@ */ public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL); + /** + * Gets the source module providing the source data. + * + * @param array $definition + * The field plugin definition. + * + * @return string|null + * The source module or NULL if not found. + */ + public function getSourceModule($definition); + + /** + * Gets the destination module handling the destination data. + * + * @param array $definition + * The field plugin definition. + * + * @return string|null + * The destination module or NULL if not found. + */ + public function getDestinationModule($definition); }