diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index 392958a..6c5b993 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -211,13 +211,9 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem /** * {@inheritdoc} */ - public function getSourcePlugin($cache = TRUE) { + public function getSourcePlugin() { if (!isset($this->sourcePlugin)) { - $source_plugin = \Drupal::service('plugin.manager.migrate.source')->createInstance($this->source['plugin'], $this->source, $this); - if ($cache) { - $this->sourcePlugin = $source_plugin; - } - return $source_plugin; + $this->sourcePlugin = \Drupal::service('plugin.manager.migrate.source')->createInstance($this->source['plugin'], $this->source, $this); } return $this->sourcePlugin; } @@ -225,6 +221,16 @@ public function getSourcePlugin($cache = TRUE) { /** * {@inheritdoc} */ + public function setSourceConfig($source_config) { + $this->source = $source_config; + // Invalidate the source plugin. + unset($this->sourcePlugin); + return $this; + } + + /** + * {@inheritdoc} + */ public function getProcessPlugins(array $process = NULL) { if (!isset($process)) { $process = $this->process; diff --git a/core/modules/migrate/src/Entity/MigrationInterface.php b/core/modules/migrate/src/Entity/MigrationInterface.php index fc575a2..7cad147 100644 --- a/core/modules/migrate/src/Entity/MigrationInterface.php +++ b/core/modules/migrate/src/Entity/MigrationInterface.php @@ -108,6 +108,20 @@ public function getSourcePlugin(); /** + * Set the source config for the source plugin. + * + * Warning, you should not use this method unless you have to. This method + * invalidates the source plugin which could cause issues if done during at + * the wrong time. + * + * @param array $source_config + * The new migration source configuration. + * + * @return $this + */ + public function setSourceConfig($source_config); + + /** * Returns the process plugins. * * @param array $process diff --git a/core/modules/migrate_drupal/src/MigrationStorage.php b/core/modules/migrate_drupal/src/MigrationStorage.php index 33b85b5..b3cea33 100644 --- a/core/modules/migrate_drupal/src/MigrationStorage.php +++ b/core/modules/migrate_drupal/src/MigrationStorage.php @@ -154,7 +154,7 @@ protected function applyCckFieldProcessors(array $entities) { // If this is a CCK bundle migration, allow the cck field plugins to add // any field type processing. $source_plugin = $migration->getSourcePlugin(FALSE); - if ($source_plugin instanceof CckFieldMigrateSourceInterface && count($migration->get('load')) === 0) { + if ($source_plugin instanceof CckFieldMigrateSourceInterface && $source_plugin->getDerivativeId()) { $plugins = $this->getCckFieldPlugins(); foreach ($source_plugin->fieldData() as $field_name => $data) { if (isset($plugins[$data['type']])) { diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateFileTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateFileTest.php index acbcd24..44bf49b 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFileTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFileTest.php @@ -36,11 +36,12 @@ protected function setUp() { $dumps = array( $this->getDumpDirectory() . '/Files.php', ); + /** @var \Drupal\migrate\Entity\MigrationInterface $migration */ $migration = entity_load('migration', 'd6_file'); - $source = $migration->get('source'); - $source['conf_path'] = 'core/modules/simpletest'; - $migration->set('source', $source); + $source = $migration->get('source') + ['conf_path' => 'core/modules/simpletest']; + $migration->setSourceConfig($source); + $this->prepare($migration, $dumps); $executable = new MigrateExecutable($migration, $this); $executable->import(); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFileTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFileTest.php index 3627964..5f5cae3 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFileTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFileTest.php @@ -37,9 +37,9 @@ protected function setUp() { ); /** @var \Drupal\migrate\Entity\MigrationInterface $migration */ $migration = entity_load('migration', 'd6_user_picture_file'); - $source = $migration->get('source'); - $source['conf_path'] = 'core/modules/simpletest'; - $migration->set('source', $source); + $source = $migration->get('source') + ['conf_path' => 'core/modules/simpletest']; + $migration->setSourceConfig($source); + $this->prepare($migration, $dumps); $executable = new MigrateExecutable($migration, $this); $executable->import();