Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295267

MigrationLookup doesn't create stub when there's multiple migrations.

$
0
0

When you have multiple source migrations like this:

process:
  uid:
    plugin: migration_lookup
    migration: 
      - users
      - members
    source: author

the documentation says that

If the migration does not find the source ID in the migration map it will create a stub entity for the relationship to use. This stub is generated by the migration provided. In the case of multiple migrations the first value of migration list will be used, but you can select the migration you wish to use to create the stub

Even the code seems to suggest that that is the intention:

    if (!$destination_ids && ($self || isset($this->configuration['stub_id']) || count($migrations) == 1)) {
      // If the lookup didn't succeed, figure out which migration will do the
      // stubbing.
      if ($self) {
        $migration = $this->migration;
      }
      elseif (isset($this->configuration['stub_id'])) {
        $migration = $migrations[$this->configuration['stub_id']];
      }
      else {
        $migration = reset($migrations);
      }

But that last else can never be reached.
$destination_ids is empty so that part of the condition is satisfied.
count($migrations) equals 2 so the last part of the condition is ignored.
This means that either $self is true or $this->configuration['stub_id'] is set.
In the first case the top branch of the if/elseif/else is executed
In the second case the middle branch is executed.
The third can never be executed.

Workaround: specify a stub_id in your migration.


Viewing all articles
Browse latest Browse all 295267

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>