It's confusing when you see $migration in the transform() method because you're not sure at first whether it means the current migration, or the lookup migration.

You can deduce it from this:

    $migrations = $this->migrationPluginManager->createInstances($migration_ids);
    foreach ($migrations as $migration_id => $migration) {

but it would be better DX to call these $lookup_migrations => $lookup_migration

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

msankhala’s picture

msankhala’s picture

Status: Active » Needs review
surbz’s picture

Hi @mahesh thanks for the patch I can confirm this applies cleanly on branch 8.6.x-dev.Just one small thing for joachim may be....

Hi @joachim do you think using $migration_lookups instead of $lookup_migrations and $migration_lookup instead of $lookup_migration makes more sense while naming this variable, the name of file being ../MigrationLookup.php

joachim’s picture

> Hi @joachim do you think using $migration_lookups instead of $lookup_migrations and $migration_lookup instead of $lookup_migration makes more sense while naming this variable, the name of file being ../MigrationLookup.php

To me, the class name MigrationLookup is about the action: a lookup using a migration.

Whereas $lookup_migrations is some migrations which are used for lookup.

surbz’s picture

Status: Needs review » Reviewed & tested by the community
quietone’s picture

Status: Reviewed & tested by the community » Needs work

@msankhala, thanks for the patch. Clarifying code is always welcome.

On review I have one question and one change.

The transform method begins with this block where $migration_ids refers to the migrations to be looked up, which the suggestion is to call them $lookup_migration. So, shouldn't this be changed to $lookup_migrations_id and $lookup_migrations_ids?

    $migration_ids = $this->configuration['migration'];
    if (!is_array($migration_ids)) {
      $migration_ids = [$migration_ids];
    }


+++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
@@ -155,11 +155,11 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
+    /** @var \Drupal\migrate\Plugin\MigrationInterface[] $lookup_migrations */

This should be moved to the line before $lookup_migrations is first used.

msankhala’s picture

Hi @quietone, Thanks for the review. Yes I agree with your suggestion about moving /** @var \Drupal\migrate\Plugin\MigrationInterface[] $lookup_migrations */ right above $lookup_migrations is first used.

Actually, it was already there so I left it unmodified. But I am happy to modify it.

The transform method begins with this block where $migration_ids refers to the migrations to be looked up, which the suggestion is to call them $lookup_migration. So, shouldn't this be changed to $lookup_migrations_id and $lookup_migrations_ids?

Yes, calling them $lookup_migrations_ids and $lookup_migration_id make more sense. It was not explicitly mentioned in scope of the issue so i left it.

I would like to know @joachim's opinion on this.

msankhala’s picture

removed duplicate comment.

quietone’s picture

@msankhala, thanks for continuing to work on this.

I think it is ok to go ahead and make the changes. Why? Because when I read the issue it states that the meaning of $migrations is deduced from reading the foreach block not that the change is limited to foreach block.

For the inline @var I mean that that should be zero lines between it and where $lookup_migrations is first used. When I apply the patch there are 2 intervening lines.

msankhala’s picture

Here is updated patch.

quietone’s picture

Assigned: Unassigned » quietone

assigning for review

quietone’s picture

Assigned: quietone » Unassigned
Status: Needs review » Reviewed & tested by the community

Installed the patch and read the code. Much better and easier to follow. I was troubled for a while with the double plural of 'lookup_migrations_ids' but since there could be multiple migrations to lookup and they could have multiple ids, it make some sense. So, yes let's move this along.

And the inline doc comment was moved as well.

Status: Reviewed & tested by the community » Needs work
msankhala’s picture

Status: Needs work » Needs review

Looks like testbot hickup. Rescheduling test.

maxocub’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

Status: Reviewed & tested by the community » Needs work
msankhala’s picture

This is kind of weird. Why test boat is only showing PHP 7 & MySQL 5.5 Build Successful instead of showing the number of tests being passed. Any idea?

maxocub’s picture

Status: Needs work » Reviewed & tested by the community

I think the testbot failures have been resolved, back to RTBC.

Status: Reviewed & tested by the community » Needs work
lomasr’s picture

Patch applied cleanly not sure why it failed by testbot.

lomasr’s picture

Status: Needs work » Needs review
msankhala’s picture

I'll check if patch needs reroll. Here is failure reason.

Patch Failed to Apply - View results on dispatcher

error: patch failed: core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php:150
error: core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php: patch does not apply
msankhala’s picture

Issue tags: +Needs reroll

Yes this needs reroll.

msankhala’s picture

Status: Needs review » Needs work
msankhala’s picture

Status: Needs work » Needs review
FileSize
4.3 KB

MigrationLookup file recently changed in https://cgit.drupalcode.org/drupal/commit/core/modules/migrate/src/Plugi...

Here is the rerolled patch.

msankhala’s picture

Issue tags: -Needs reroll
msankhala’s picture

quietone’s picture

Issue tags: +Needs reroll

Adding reroll tag

leolandotan’s picture

Assigned: Unassigned » leolandotan

I'll work on the reroll of this patch.

leolandotan’s picture

Assigned: leolandotan » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.66 KB

Hi guys,

I have rerolled the patch following Rerolling patches and Rerolling patches: Failed Rebase. Unfortunately, there was a conflict when I did the reroll specifically in what @msankhala shared from https://cgit.drupalcode.org/drupal/commit/core/modules/migrate/src/Plugi.... Basically the change conflicts fixes were to:

  1. Transfer the var comment above `$destination_ids = NULL;` instead of directly above the `$lookup_migrations` declaration.
  2. Remove the "If no migrations are loaded it means..." comment section based on the latest changes from the provided issue ticket.
  3. Remove the MigrateException `if` block based also on the latest changes from the provided issue ticket.

Hope everything is in order.

Thanks!

heddn’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

This re-name will definitely make it easier to read the code. Great fixes.

Status: Reviewed & tested by the community » Needs work
msankhala’s picture

Status: Needs work » Needs review

Looks like an issue with test bot. Putting it to Need review again. Once passed it is ready for RTBC.

maxocub’s picture

Status: Needs review » Reviewed & tested by the community

Tests are green, back to RTBC.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Title: change variable names in MigrationLookup » Improve variable names in MigrationLookup for DX

Add tag for DX and change title

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This is definitely an improvement but I think if we're addressing all the $migration(s) confusion we have one more thing to address:

+++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
@@ -184,17 +186,17 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
       // 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']];
+        $migration = $lookup_migrations[$this->configuration['stub_id']];
       }
       else {
-        $migration = reset($migrations);
+        $migration = reset($lookup_migrations);
       }

I think we should consider renaming $migration here too. Because it's not always the $migration in progress. Maybe we should go for something like $stub_migration?

msankhala’s picture

Status: Needs work » Needs review
FileSize
4.87 KB
2.27 KB

Here is the updated patch as per @alexpott suggestion in #38.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. Feedback in #38 is addressed.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 37f6cce and pushed to 8.7.x. Thanks!

  • catch committed 37f6cce on 8.7.x
    Issue #2963811 by msankhala, quietone, joachim: Improve variable names...
maxocub’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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