diff --git a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php index 4b8ad92..532ab6e 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php @@ -23,7 +23,7 @@ class Iterator extends ProcessPluginBase { */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $return = array(); - if (is_array($value)) { + if (!is_null($value)) { foreach ($value as $key => $new_value) { $new_row = new Row($new_value, array()); $migrate_executable->processRow($new_row, $this->configuration['process']); diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php index 0c5a9e4..3d325eb 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php @@ -3729,6 +3729,15 @@ 'data' => 'a:7:{s:5:"label";s:7:"Integer";s:6:"widget";a:5:{s:6:"weight";s:1:"2";s:4:"type";s:6:"number";s:6:"module";s:6:"number";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:5:{s:3:"min";s:0:"";s:3:"max";s:0:"";s:6:"prefix";s:0:"";s:6:"suffix";s:0:"";s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:14:"number_integer";s:8:"settings";a:4:{s:18:"thousand_separator";s:0:"";s:17:"decimal_separator";s:1:".";s:5:"scale";i:0;s:13:"prefix_suffix";b:1;}s:6:"module";s:6:"number";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}', 'deleted' => '0', )) +->values(array( + 'id' => '35', + 'field_id' => '20', + 'field_name' => 'field_term_reference', + 'entity_type' => 'taxonomy_term', + 'bundle' => 'test_vocabulary', + 'data' => 'a:7:{s:5:"label";s:14:"Term Reference";s:6:"widget";a:5:{s:6:"weight";s:2:"14";s:4:"type";s:21:"taxonomy_autocomplete";s:6:"module";s:8:"taxonomy";s:6:"active";i:0;s:8:"settings";a:2:{s:4:"size";i:60;s:17:"autocomplete_path";s:21:"taxonomy/autocomplete";}}s:8:"settings";a:1:{s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:4:{s:5:"label";s:5:"above";s:4:"type";s:6:"hidden";s:6:"weight";s:2:"13";s:8:"settings";a:0:{}}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}', + 'deleted' => '0', +)) ->execute(); $connection->schema()->createTable('field_data_body', array( @@ -5260,6 +5269,16 @@ 'delta' => '0', 'field_term_reference_tid' => '4', )) +->values(array( + 'entity_type' => 'taxonomy_term', + 'bundle' => 'test_vocabulary', + 'deleted' => '0', + 'entity_id' => '2', + 'revision_id' => '2', + 'language' => 'und', + 'delta' => '0', + 'field_term_reference_tid' => '3', +)) ->execute(); $connection->schema()->createTable('field_data_field_text', array( @@ -7042,6 +7061,16 @@ 'delta' => '0', 'field_term_reference_tid' => '4', )) +->values(array( + 'entity_type' => 'taxonomy_term', + 'bundle' => 'test_vocabulary', + 'deleted' => '0', + 'entity_id' => '2', + 'revision_id' => '2', + 'language' => 'und', + 'delta' => '0', + 'field_term_reference_tid' => '3', +)) ->execute(); $connection->schema()->createTable('field_revision_field_text', array( diff --git a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php index c802aad..6eaafe7 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php @@ -41,8 +41,8 @@ protected function getEntityCounts() { 'comment_type' => 7, 'contact_form' => 3, 'editor' => 2, - 'field_config' => 42, - 'field_storage_config' => 32, + 'field_config' => 43, + 'field_storage_config' => 33, 'file' => 1, 'filter_format' => 7, 'image_style' => 6, diff --git a/core/modules/taxonomy/migration_templates/d7_taxonomy_term.yml b/core/modules/taxonomy/migration_templates/d7_taxonomy_term.yml index d504f2d..6c7b751 100644 --- a/core/modules/taxonomy/migration_templates/d7_taxonomy_term.yml +++ b/core/modules/taxonomy/migration_templates/d7_taxonomy_term.yml @@ -25,3 +25,5 @@ destination: migration_dependencies: required: - d7_taxonomy_vocabulary + optional: + - d7_field_instance diff --git a/core/modules/taxonomy/src/Plugin/migrate/Term.php b/core/modules/taxonomy/src/Plugin/migrate/Term.php index 6519437..45a5661 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/Term.php +++ b/core/modules/taxonomy/src/Plugin/migrate/Term.php @@ -2,83 +2,13 @@ namespace Drupal\taxonomy\Plugin\migrate; -use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\migrate\Exception\RequirementsException; -use Drupal\migrate\Plugin\MigrateDestinationPluginManager; -use Drupal\migrate\Plugin\MigratePluginManager; -use Drupal\migrate\Plugin\Migration; -use Drupal\migrate\Plugin\MigrationPluginManagerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\migrate_drupal\Plugin\migrate\CckMigration; /** * Plugin class for Drupal 7 taxonomy term migrations dealing with fields. */ -class Term extends Migration { - - /** - * Flag indicating whether the CCK data has been filled already. - * - * @var bool - */ - protected $init = FALSE; - - /** - * Already-instantiated cckfield plugins, keyed by ID. - * - * @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[] - */ - protected $cckPluginCache; - - /** - * The CCK plugin manager. - * - * @var \Drupal\Component\Plugin\PluginManagerInterface - */ - protected $cckPluginManager; - - /** - * Constructs a User Migration. - * - * @param array $configuration - * Plugin configuration. - * @param string $plugin_id - * The plugin ID. - * @param mixed $plugin_definition - * The plugin definition. - * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager - * The migration plugin manager. - * @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager - * The source migration plugin manager. - * @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager - * The process migration plugin manager. - * @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager - * The destination migration plugin manager. - * @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager - * The ID map migration plugin manager. - * @param \Drupal\Component\Plugin\PluginManagerInterface $cck_manager - * The CCK plugin manager. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManager $source_plugin_manager, MigratePluginManager $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManager $idmap_plugin_manager, PluginManagerInterface $cck_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration_plugin_manager, $source_plugin_manager, $process_plugin_manager, $destination_plugin_manager, $idmap_plugin_manager); - $this->cckPluginManager = $cck_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('plugin.manager.migration'), - $container->get('plugin.manager.migrate.source'), - $container->get('plugin.manager.migrate.process'), - $container->get('plugin.manager.migrate.destination'), - $container->get('plugin.manager.migrate.id_map'), - $container->get('plugin.manager.migrate.cckfield') - ); - } +class Term extends CckMigration { /** * {@inheritdoc} diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php index b0a0753..e967337 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php @@ -59,10 +59,10 @@ protected function setUp() { * The weight the migrated entity should have. * @param array $expected_parents * The parent terms the migrated entity should have. - * @param int $expected_field_value + * @param int $expected_field_integer_value * The value the migrated entity field should have. */ - protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = [], $expected_field_value = NULL) { + protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = [], $expected_field_integer_value = NULL, $expected_term_reference_tid = NULL) { /** @var \Drupal\taxonomy\TermInterface $entity */ $entity = Term::load($id); $this->assertTrue($entity instanceof TermInterface); @@ -72,9 +72,13 @@ protected function assertEntity($id, $expected_label, $expected_vid, $expected_d $this->assertEquals($expected_format, $entity->getFormat()); $this->assertEqual($expected_weight, $entity->getWeight()); $this->assertIdentical($expected_parents, $this->getParentIDs($id)); - if (!is_null($expected_field_value)) { + if (!is_null($expected_field_integer_value)) { $this->assertTrue($entity->hasField('field_integer')); - $this->assertEquals($expected_field_value, $entity->field_integer->value); + $this->assertEquals($expected_field_integer_value, $entity->field_integer->value); + } + if (!is_null($expected_term_reference_tid)) { + $this->assertTrue($entity->hasField('field_integer')); + $this->assertEquals($expected_term_reference_tid, $entity->field_term_reference->target_id); } } @@ -83,7 +87,7 @@ protected function assertEntity($id, $expected_label, $expected_vid, $expected_d */ public function testTaxonomyTerms() { $this->assertEntity(1, 'General discussion', 'forums', '', NULL, 2); - $this->assertEntity(2, 'Term1', 'test_vocabulary', 'The first term.', 'filtered_html'); + $this->assertEntity(2, 'Term1', 'test_vocabulary', 'The first term.', 'filtered_html', 0, [], NULL, 3); $this->assertEntity(3, 'Term2', 'test_vocabulary', 'The second term.', 'filtered_html'); $this->assertEntity(4, 'Term3', 'test_vocabulary', 'The third term.', 'full_html', 0, [3], 6); $this->assertEntity(5, 'Custom Forum', 'forums', 'Where the cool kids are.', NULL, 3);