Problem/Motivation

Document and rename the 'migration' process plugin because its name is not intuitive and we need better docs.

Proposed resolution

Rename to 'migration_lookup'.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

quietone created an issue. See original summary.

quietone’s picture

Status: Active » Needs review
StatusFileSize
new4.05 KB
phenaproxima’s picture

Assigned: Unassigned » phenaproxima

Self-assigning for review.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

heddn’s picture

Title: Add documentation to Migration process plugin » Add documentation and rename to Migration process plugin
Issue summary: View changes
joachim’s picture

+1 to the name change.

  1. +++ b/core/modules/migrate/src/Plugin/migrate/process/Migration.php
    @@ -16,7 +16,120 @@
    + *   - source_ids:
    + *   - stub_id:
    

    Missing descriptions.

  2. +++ b/core/modules/migrate/src/Plugin/migrate/process/Migration.php
    @@ -16,7 +16,120 @@
    + * migrated the user accounts in a migration named users, you would specify the
    

    Put quote marks on the name of the migration 'users'. Or better, give it a more distinctive name, such as users_migration. That avoids it also looking like a DB table name.

joachim’s picture

Actually, now I think about it, the change of a plugin name should really happen in a separate issue from documentation. One is quite a dramatic change that should be clearly signposted in git logs and release notes; the other is fairly uncontentious.

heddn’s picture

jofitz’s picture

Assigned: phenaproxima » Unassigned
StatusFileSize
new1.09 KB
new4.24 KB

Changes in response to @joachim's code review in #6.

@todo: process plugin rename.

jofitz’s picture

Status: Needs review » Needs work

Setting back to Needs Work to rename the process plugin.

quietone’s picture

Title: Add documentation and rename to Migration process plugin » Rename Migration process plugin and add documentation
jofitz’s picture

Does anyone have any suggestions for the new name of this plugin? Reading through the documentation here's the best I can come up with:

  • Relationship
  • Connection
  • Maintain integrity

If we can settle on a name then I am happy to make the change and push this one through - it has been sitting around too long for such a basic change.

mikeryan’s picture

reference_lookup? relationship_lookup? Or, migration_lookup from the issue summary? I think the key point is that the source value is used to perform a lookup against the results of another migration...

quietone’s picture

Yes, migration_lookup is the way to go.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new39.24 KB
new41.84 KB
  • Deprecated the Migration process.
  • Added the MigrationLookup process.
  • Pointed the tests to MigrationLookup
  • Updating current uses of migration to migration_lookup.

Status: Needs review » Needs work

The last submitted patch, 15: 2845486-15.patch, failed testing.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new39.89 KB
new1.52 KB
new42.57 KB

Let's pretend we didn't see that #embarrassed

mikeryan’s picture

Status: Needs review » Needs work

Thanks, here's my first round of feedback:

  1. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + * Calculates the value of a property based on a previous migration.
    

    I'd say "Looks up" rather than "Calculates".

  2. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + * created from it may have a uid of 456. The migration_lookup process maintains
    + * the relationships between source and destination identifiers in map tables,
    + * and this information is leveraged by the migration process plugin.
    

    It's not the migration_lookup plugin that maintains the relationship, but it is that plugin which leverages the information. So, swap "migration_lookup process" and "migration process".

  3. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + * - migration: An array of migration ids.
    

    , or a single migration ID.

  4. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + *
    

    no_stub should also be documented here.

  5. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + *   uid:
    + *   plugin: migration_lookup
    + *   migration:
    + *     - users
    + *     - members
    + *   source_ids:
    + *     users:
    + *       - author
    + *     members:
    + *       - author
    

    Everything after "uid:" needs to be indented.

    It would be a clearer demonstration of the use case to have different source_ids for the different migrations.

  6. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + * If the migration_lookup does not find the source ID in the migration map it
    

    s/migration_lookup/migration_lookup plugin/

  7. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + * of migration list will be used, but you can select the migration you wish to
    

    "the" before "migration list".

  8. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + * use to create the stub:
    

    Should add something like "using the stub_id configuration key".

  9. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + *     source_ids:
    + *       users:
    + *         - author
    + *       members:
    + *         - author
    

    Let's take the source_ids out of this example.

  10. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + *   plugin: migration_lookup
    + *   migration: users
    + *   no_stub: true
    + *   source: author
    

    Indentation.

  11. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,291 @@
    + * Scenario:
    + *   - field_drupal6_pages is a drupal 6 node reference field.
    + *   - field_drupal8_pages is a drupal 8 entity reference field.
    

    ...
    Do we need these scenarios? Everything we need already has documentation.

  12. +++ b/core/modules/migrate/tests/modules/migrate_external_translated_test/migrations/migrate.migration.external_translated_test_node_translation.yml
    similarity index 90%
    rename from core/modules/migrate/tests/src/Unit/process/MigrationTest.php
    
    rename from core/modules/migrate/tests/src/Unit/process/MigrationTest.php
    rename to core/modules/migrate/tests/src/Unit/process/MigrationLookupTest.php
    

    We should copy rather than rename (thus having near-duplicate tests) so the BC layer is tested.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new47.37 KB
new14.55 KB

Fixed
1, 2, 3. (but I liked the single first. ), 6, 7, 10 and 12.

TODO
4, 5 (changed the text but not the example), 8, 9 and 11

quietone’s picture

Status: Needs review » Needs work

Needs work for #18: 4, 5 (changed the text but not the example), 8, 9 and 11.

gaurav.kapoor’s picture

Assigned: Unassigned » gaurav.kapoor
gaurav.kapoor’s picture

Assigned: gaurav.kapoor » Unassigned
Status: Needs work » Needs review
StatusFileSize
new47.31 KB
new1.36 KB

Fixed

phenaproxima’s picture

Status: Needs review » Needs work

I'm digging this extensive documentation. Great work. Migration lookup is very hard to explain (lots of facets to it) and you've all done a beautiful job. I have a few complaints:

  1. +++ b/core/modules/migrate/src/Plugin/migrate/process/Migration.php
    @@ -21,156 +10,8 @@
    + * @deprecated in Drupal 8.3.x and will be removed in Drupal 9.0.x. Use
    + *   \Drupal\migrate\Plugin\migrate\process\MigrationLookup instead.
    

    Nit: I believe these two lines should be flush with each other.

  2. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * change in the process of migration. For example, on the source site a given
    + * user account may have an "author" ID of 123, but the Drupal user account
    

    Should be "For example, on the source site, a given user account may have an ID of 123..."

  3. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * - migration: A single migration id, or an array of migration ids.
    

    'id' should be 'ID', and 'ids' should be 'IDs'.

  4. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * - source_ids: (optional) An array keyed by migration ids with values that are
    

    IDs

  5. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * - stub_id: (optional) Identifies which entry in the migration array will be
    + *   used to create any stub entities.
    

    Can this be "Identifies the migration which will be used to create any stub entities"?

  6. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * The value of migration can be a list of migration ids. When using multiple
    

    Can this be "'migration' can be a list of migration IDs"?

  7. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * case one can use source_ids which is an array keyed by the migration ids
    

    IDs

  8. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * and the value is a list of source properties with the same features as normal
    + * source (see the get plugin for more on this).
    

    The end of this sentence is really unclear. Off the top of my head I'm not sure how to rephrase it, but I think it is confusing as-is. It sounds important, but is hard to grok.

  9. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * migration you wish to* by using the stub_id configuration key:
    

    Should be "...the migration you wish to use..."

  10. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * Here, the value of stub_id selects the members migration to create any stub
    + * entities, overriding the default of the users migration.
    

    I think we should remove everything after the final comma ("entities, overriding..."). The word "overriding" muddies the clarity of the sentence.

  11. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + * migration map, use no_stub. It can be set to any non-empty value:
    

    Let's remove the last sentence and put a colon after "use no_stub". As far as developers need be concerned, no_stub is a boolean value.

  12. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + *   - field_drupal6_pages is a drupal 6 node reference field.
    + *   - field_drupal8_pages is a drupal 8 entity reference field.
    

    "drupal" should be capitalized.

  13. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,286 @@
    + *   - field_drupal7_pages is a drupal 7 entity reference field.
    + *   - field_drupal8_pages is a drupal 8 entity reference field.
    

    Ditto.

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new28.99 KB
new4.1 KB

Sorry @Yogesh Pawar, I've already done this one. Perhaps I should've self-assigned.

jofitz’s picture

Assigned: yogeshmpawar » Unassigned
StatusFileSize
new47.13 KB

Well, I screwed that up! Here's the actual patch.

yogeshmpawar’s picture

It's okay @Jo Fitzgerald no problem.

yogeshmpawar’s picture

StatusFileSize
new47.13 KB
new691 bytes

I think you missed one thing #23.1 so added updated patch with interdiff.

jofitz’s picture

Aww, I should've mentioned that I'd discussed that with @phenaproxima in IRC and we'd decided to not make that change. Oh well, it's there now and you have made your contribution. Everyone's happy :)

The last submitted patch, 25: 2845486-24.patch, failed testing.

mikeryan’s picture

Status: Needs review » Needs work

Some of my feedback in #18 has not been addressed:

  1. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,285 @@
    + * - stub_id: (optional) Identifies the migration which will be used to create
    + *   any stub entities.
    + *
    

    no_stub should also be listed here.

  2. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,285 @@
    + *       source_ids:
    + *         users:
    + *           - author
    + *         members:
    + *           - author
    

    The source keys here should be different (otherwise this would be unnecessary).

  3. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,285 @@
    + * Scenario:
    + *   - field_drupal6_pages is a Drupal 6 node reference field.
    + *   - field_drupal8_pages is a Drupal 8 entity reference field.
    + *
    ...
    

    Again, is there a purpose to these scenarios, which don't seem to add anything to the other examples we have?

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new46.58 KB
new1.64 KB
  1. Added documentation for no_stub.
  2. Edited the "members" source_id to make sense of a convoluted example.
  3. Removed the redundant scenarios.
mikeryan’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

The patch itself is RTBC as far as I'm concerned. Just one more thing - let's have a change record for this.

heddn’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

Added a CR.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 32: 2845486-32.patch, failed testing.

phenaproxima’s picture

Status: Needs work » Reviewed & tested by the community

Drupal CI is temperamental on this fine day, but that is no reason for it to impugn so fine a patch. Back to RTBC.

quietone’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new46.58 KB
new0 bytes

Sorry to do this.

In item 12 of comment #18, mikeryan says,

We should copy rather than rename (thus having near-duplicate tests) so the BC layer is tested.

And then I posted a patch which should have included that, but it didn't. This patch fixes restores that test.

quietone’s picture

Status: Needs review » Needs work

Looks odd to see an empty interdiff. But it is correct. Instead of moving MigrationTest to MigrationLookupTest, and having one test, this patch did a copy of MigrationTest to MigrationLookupTest, leaving two tests. Migration test is the original and MigrationLookup is the new.

But, I just realized that MigrationTest needs to have deprecation added to it.

quietone’s picture

Oh fudge, the patch is wrong.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new47.75 KB
new1.45 KB

Actually, no it was ok. I am clearly more stressed about missing my holiday that I thought. Anyway, lets try again. This patch adds deprecation notices for MigrationTest. However, I am at the airport and learned that our flight is delayed, such that we miss our connecting flight. Maybe more mistakes are here!

heddn’s picture

Status: Needs review » Needs work
Issue tags: +Novice

Some small nits. Tagging novice for the docs updates.

  1. +++ b/core/modules/migrate/tests/src/Unit/process/MigrationTest.php
    @@ -14,6 +17,9 @@
    + *   \Drupal\Tests\migrate\Unit\processMigrationLookupTest instead.
    

    Nit: missing a slash between process\MigrationLookupTest

  2. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,261 @@
    + * source site, but in most instances the unique identifiers of the content
    

    "Most" provides a value judgement that doesn't add value and isn't necessarily true. Let's avoid that dilemma and remove it entirely.

  3. +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
    @@ -0,0 +1,261 @@
    + * Here, the value of stub_id selects the members migration to create any stub
    + * entities.
    

    It isn't clear that these lines refer to the code example above it.

shabana.navas’s picture

Status: Needs work » Needs review
StatusFileSize
new47.93 KB
new1.85 KB

Applied changes from comments in #41.

heddn’s picture

Status: Needs review » Needs work
+++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php
@@ -17,8 +17,7 @@
  * It is important to maintain relationships among content coming from the
- * source site, but in most instances the unique identifiers of the content
- * change in the process of migration. For example, on the source site, a given
+ * source site. For example, on the source site, a given
  * user account may have an ID of 123, but the Drupal user account created from
  * it may have a uid of 456. The migration process maintains the relationships
  * between source and destination identifiers in map tables, and this

Super small nit, but could we get all these lines to line up with the 80 character limit? With the clean-up of the comment, there is plenty of space to re-flow the text.

gaurav.kapoor’s picture

Status: Needs work » Needs review
StatusFileSize
new47.67 KB
new1.26 KB
heddn’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice
phenaproxima’s picture

catch’s picture

Status: Reviewed & tested by the community » Needs work

This looks great to me. When phenaproxima verbally described the issue I got confused by 'migration ' as in "migration migration process plugin", so "migration lookup process plugin" is a lot easier to figure out.

DrupalCS isn't happy though:

PHPCS: core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php passed

FILE: ....x/core/modules/migrate/src/Plugin/migrate/process/Migration.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 5 | ERROR | [x] Concat operator must be surrounded by a single space
 6 | ERROR | [x] Concat operator must be surrounded by a single space
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 17ms; Memory: 4Mb

PHPCS: core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php passed

FILE: ...e/modules/migrate/tests/src/Unit/process/MigrationLookupTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 93 | WARNING | @expectedException tags should not be used, use
    |         | $§this->setExpectedException() or
    |         | $this->expectException() instead
----------------------------------------------------------------------

Time: 37ms; Memory: 6Mb


FILE: ....x/core/modules/migrate/tests/src/Unit/process/MigrationTest.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 5 | ERROR | [x] Concat operator must be surrounded by a single space
 6 | ERROR | [x] Concat operator must be surrounded by a single space
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 39ms; Memory: 6Mb
heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new38.07 KB
new3.09 KB
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. Back to RTBC assuming Drupal CI passes.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 48: 2845486_48.patch, failed testing.

phenaproxima’s picture

Issue tags: +Needs reroll
phenaproxima’s picture

Issue tags: +Novice
ohthehugemanatee’s picture

StatusFileSize
new46.92 KB

Had to re-roll core/modules/migrate/tests/src/Unit/process/MigrationLookupTest.php to account for changes in d66aaae6c77cca28eb0cec31588c00c7778d9d55 . Interdiff is ugly and not usable.

ohthehugemanatee’s picture

Status: Needs work » Needs review
heddn’s picture

StatusFileSize
new42.82 KB
new2.76 KB

OK, I think I mucked that patch up a bit in #48. Let's try this. Interdiff against 44.

ohthehugemanatee’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new42.82 KB

Renamed that patch to .patch

ohthehugemanatee’s picture

Status: Reviewed & tested by the community » Needs review

This should really only be RTBC when the patch goes green.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

It came back green.

jofitz’s picture

Issue tags: -Needs reroll
catch’s picture

Issue summary: View changes
Issue tags: -Novice
StatusFileSize
new42.75 KB
new664 bytes

On renaming in the docs issue, it's a bit tricky because renaming would mean updating some documentation, but actually writing the full documentation relies on the rename (at least in these two cases) - so we'd have two patches with a direct dependency. On the other hand it's made this patch a bit harder to review since the diff is quite large. So not sure what's best with that.

There was still one phpcs violation in the patch, I think it's just this stray line but since the annotation is used by phpunit, uploading a patch just in case rather than directly fixing on commit. Leaving RTBC will commit once this comes back green.

  • catch committed d15ee71 on 8.4.x
    Issue #2845486 by Jo Fitzgerald, quietone, gaurav.kapoor,...
catch’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.4.x and cherry-picked to 8.3.x. Thanks!

Status: Fixed » Closed (fixed)

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

heddn’s picture

Issue tags: +8.4.0 release notes

Tagging for mention in 8.4.0 release notes.

xjm’s picture

Issue tags: -8.4.0 release notes

The change record should be sufficient to capture the API improvement here since it has BC, but we'll include a bullet in the release notes for these and other Migrate and Migrate Drupal API improvements. Thanks!

xjm’s picture

Ah, looks like this one was also backported to 8.3.x.