The Migration Lookup process plugin accepts a configuration key 'source_ids' which is an associative array, keyed by migration id, of source ids for a multi-migration lookup. When processing the Migrations and adding a prefix to migration ids, the keys of this configuration array are not prefixed, breaking the migration.

What should happen:
The keys of this array should receive the same prefix that all the other migrations receive so that the migrate_lookup plugin can process them properly.

Comments

mikelutz created an issue. See original summary.

mikelutz’s picture

mikelutz’s picture

mikelutz’s picture

mikelutz’s picture

I am going to assume the last one will finally successfully fail...

Here's the patch to hopefully fix.

mikelutz’s picture

Status: Active » Needs review
quietone’s picture

Status: Needs review » Needs work

@mikelutz, thanks for the patch, it looks good and works just fine. I do have a few comments.

  1. +++ b/src/MigrateUpgradeDrushRunner.php
    @@ -258,6 +258,14 @@ class MigrateUpgradeDrushRunner {
    +        if (isset($process['source_ids']) && is_array($process['source_ids'])) {
    

    Can we have a comment here explaining why this is needed?

  2. +++ b/tests/src/Unit/MigrateUpgradeDrushRunnerTest.php
    @@ -0,0 +1,180 @@
    +            'source' => [
    +              'plugin' => 'my_source_plugin',
    +            ],
    

    Not really needed in the test, the runner doesn't change the source values. Let's keep this simple.

  3. +++ b/tests/src/Unit/MigrateUpgradeDrushRunnerTest.php
    @@ -0,0 +1,180 @@
    +            'destination' => [
    +              'plugin' => 'my_destination',
    +            ],
    

    Ditto.

  4. +++ b/tests/src/Unit/MigrateUpgradeDrushRunnerTest.php
    @@ -0,0 +1,180 @@
    +            'migration_dependencies' => [
    +              'required' => ['required_dependency'],
    +              'optional' => ['optional_dependency'],
    

    But here let's add a previous migration as a dependency for both required and optional and test that they are updated with the prefix as well.

  5. +++ b/tests/src/Unit/MigrateUpgradeDrushRunnerTest.php
    @@ -0,0 +1,180 @@
    +  use Drupal\migrate_upgrade\MigrateUpgradeDrushRunner;
    

    The indentation on the whole class has an extra two spaces.

  6. +++ b/tests/src/Unit/MigrateUpgradeDrushRunnerTest.php
    @@ -0,0 +1,180 @@
    +  class TestMigrateUpgradeDrushRunner extends MigrateUpgradeDrushRunner {
    

    Don't we have a requirement that there is one class per file? See Object-oriented code.

  7. +++ b/tests/src/Unit/MigrateUpgradeDrushRunnerTest.php
    @@ -0,0 +1,180 @@
    +namespace Drupal\migrate_upgrade {
    

    Ah, this file is using a structure I am not familiar with, so really can't comment.

Can someone else comment about on the structure of the test file, it has two classes and two namespaces, which I am not sure about?

mikelutz’s picture

I'm happy to add additional comments, and remove the cruft from the test case. There is plenty of precedent for adding one time use protected property/method overrides at the bottom of unit test classes.
@see core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php, core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php, etc

Using a second namespace is less common, but necessary in this case to override the drush function. There is precedent again

@see core/tests/Drupal/Tests/Core/Session/AccountProxyTest.php, core/tests/Drupal/Tests/Component/Utility/CryptRandomFallbackTest.php

I initially used bracketed namespaces, but I've replaced them with the non-bracketed declarations as they seem to be more standard.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Decent test coverage. We can improve/adjust things over time. Looking good here. Honestly, I'm glad to see test coverage at all, although I would have asked for it if we didn't have any.

  • heddn committed 1ae77bb on 8.x-3.x authored by mikelutz
    Issue #2946208 by mikelutz, quietone, heddn: Migration Lookup source_ids...
heddn’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.