Providing multiple source IDs to a migration process results in the field being skipped every time because the passed value is always NULL.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | 2796393-28.patch | 6.31 KB | jofitz |
| #28 | interdiff-26-28.txt | 926 bytes | jofitz |
| #26 | 2796393-26.patch | 5.41 KB | jofitz |
| #19 | 2796393-17-19-interdiff.txt | 975 bytes | tacituseu |
| #19 | 2796393-19-complete.patch | 8.83 KB | tacituseu |
Comments
Comment #2
stefan freudenberg commentedPlease see attached patch.
Comment #4
mikeryanThis seems to work fine in general, I've seen no such problem - can you provide more details on your case? What does your .yml look like? What about the source data passed to the migration plugin?
Comment #5
mikeryanComment #6
gaëlgI had the problem. Here are the interesting parts of my migration module.
Dependent migration:
Dependency migration:
The last patch fixed it.
Comment #7
heddnI've seen some of this interesting behavior with the migrate process plugin before. We discuss some of the limitations in: https://www.mtech-llc.com/blog/charlotte-leon/migration-csv-data-paragraphs
However, to get this going, I really think we need a test that demonstrates the problem.
Comment #8
heddnHmm, I mis-spoke. We didn't find anything interesting with migrate process plugin. It was rather iterator and extract. But we still need tests.
Comment #9
jofitzI've had a go at creating a test for this issue, but I've come up short. Here is my attempt so far, perhaps someone can extend it. No point in running the testbot on this (it passes locally, but isn't really testing anything).
Comment #10
jofitzI eventually got to the bottom of it - migrations with multiple source_ids may not (do not?) pass a value to transform() (and if they do it is ignored). But with the current location of skipOnEmpy() these rows are skipped, in error. I have tweaked and updated @Stefan Freudenberg's patch and produced a test-only patch to prove the error.
I haven't provided an interdiff because I basically worked from scratch (and suspect that the 7-month old original patch would have required a reroll anyway).
Comment #12
heddnWill review this in the coming week.
Comment #13
heddnTagging for reroll. Migration process plugin was re-named in 8.4.x. Also tagging for backport, as this is a bug and therefore could make its way back into 8.3.
My one piece of feedback about the test, there's an awful lot of mocking going on. I feel it would be easier to read the test if a Kernel test was developed that used the embedded_data, source plugin. It's a little more effort and would take longer to run, but it would also make the scenario crystal clear. @jofitz, on the other hand, this is a fairly odd one-off. So there isn't a huge need to make all tests readable and I trust this does test the scenario. It is just hard to read.
Comment #14
yogeshmpawarComment #15
yogeshmpawarRe-roll the patch against 8.3.x & 8.4.x branch for the comment #13.
Comment #17
tacituseu commentedIn my case source had hierarchy encoded in two text/string fields.
Don't know enough about migration's inner workings to comment on the solution, but it works fine after the patch.
Taking a stab at the failing test.
Comment #19
tacituseu commentedMissed a spot.
Comment #20
quietone commentedAdd related issues
Comment #21
tacituseu commentedSome examples this makes possible:
1. item has an owner which comes from one of 2 source tables, depending on type specified
2. hierarchical taxonomy encoded in source table as two varchar columns
Comment #23
heddnAssigning to myself to review this week.
Comment #24
mpp commentedNote/disclaimer: my use case may be a bit different than the one described in the comments here but it does fit the title and description of this issue. I'm documenting it here for others that may encounter the same use case.
We have several migrations that migrate from different node types in Drupal 7 to one node type in Drupal 8 (we merge "restaurant", "hotel" & "spot" into "poi").
All these source node types contain a node reference to each other for related items.
This is an example on one of the migrations:
Since the patch in #19 did not solve the issue and using a single
stub_idin this case is not an option, we extended MigrationLookup to set the proper stub_id based on a query of the node type in the source database.Comment #25
heddnNeeds re-roll. And one quick note while doing that.
This isn't needed. It is now deprecated.
Comment #26
jofitzRe-rolled.
Removed changes to MigrationTest.php because Migration.php is deprecated.
Comment #28
jofitzRemoved too much from MigrationTest.php! Corrected.
Comment #29
heddnComment #30
heddnThis has test coverage. See #10. And it fixes an issue for a fairly complicated scenario. Good work.
Comment #31
heddnTagging
Comment #32
larowlanAdding credit for reviewers and those who provided sample migrations to help get to the bottom of the issue
Comment #34
larowlanCommitted as f37dea0 and pushed to 8.5.x
Comment #36
dwwThis was never committed to the 8.4.x branch. Comment #23 removed the "Needs backport to 8.3.x" tag, but it seems this at least needs to be in 8.4.x.
Thankfully, 2796393-28.patch from #28 applies cleanly to the end of the 8.4.x branch (or the 8.4.3 tag if anyone else needs to deploy this now) and solves the bug.
I was being nailed by this via a CSV migration involving node authorship not being able to lookup UIDs from a user migration that needed multiple keys. With #28 applied, the migration is now working properly.
Back to RTBC.
Thanks!
-Derek
Comment #37
larowlanAs per https://www.drupal.org/core/release-cycle-overview#current-development-c... 8.4 is in 'critical fixes only', so this can't be backported to 8.4
Comment #38
dwwSorry, I don't want to make trouble and get in a status pushing match, but either the page you linked to is wrong, or you forgot about January. ;)
As of this writing (Jan 8th), we're still 9 days from the date when 8.5.0-alpha1 is supposed to be released, and we've got a full month before that table claims that 8.4.x is in "criticals only" mode.
Tentatively re-opening this for commit to 8.4.x. It changes no API (other than fixing a migration plugin to work as advertised), it's been multiply reviewed, comes with tests, myself and others have also manually tested, and it's already in 8.5.x.
Thanks,
-Derek
Comment #39
xjmThe next patch release window is February 7. As indicated there, is for critical issues only. This is not a critical. It will be included in 8.5.0 on March 7.
Marking back to fixed. Thanks!
Comment #41
pwolanin commentedwow - glad there is a patch here at least. I thought I was going crazy that the documented definition with 2 source_ids didn't work.
Thanks for the fix!
Comment #42
brooke_heaton commentedOne issue on the patch: The documentation on lines 63 and 75 of MigrationLookup.php is wrong. 'souce_ids' should not be indented below 'migration'