diff -u b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php --- b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php @@ -51,22 +51,25 @@ protected $cckSchemaCorrect; /** + * The d6_field source plugin. + * + * @var \Drupal\migrate\Plugin\MigrateSourceInterface + */ + protected $fieldSource; + + /** * All CCK field info in the source database, keyed by node type. * * @var array */ - protected $fieldInfo = []; + protected $fieldInfo; /** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager, MigratePluginManager $source_plugins) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $entity_manager); - - $plugin = $source_plugins->createInstance('d6_field', [], $migration); - foreach ($plugin as $row) { - $this->fieldInfo[$row->getSourceProperty('type_name')][] = $row->getSource(); - } + $this->fieldSource = $source_plugins->createInstance('d6_field', [], $migration); } /** @@ -246,6 +249,27 @@ } /** + * Returns field and field instance definitions for all fields on a given + * node type. + * + * @param string $node_type + * The node type to be queried. + * + * @return array + * An array of field and field instance definition arrays from the source + * database. + */ + protected function getFieldInfo($node_type) { + if (!isset($this->fieldInfo)) { + $this->fieldInfo = []; + foreach ($this->fieldSource as $row) { + $this->fieldInfo[$row->getSourceProperty('type_name')][] = $row->getSource(); + } + } + return @($this->fieldInfo[$node_type] ?: []); + } + + /** * Determines whether a specific CCK table exists. */ protected function tableExists($table) {