Problem/Motivation
In #30 of the parent issue phenaproxima suggested a plan for handling entity references, links, menu_items, user_ratings.
The issue is for working on the menu_items.
Proposed resolution
The issue proposed solution is:
Since menu items, as far as I know, store their canonical path, we can take a similar approach as with entity reference fields
And the proposed solution for entity_reference_fields is
Let's create more migrations to deal with this. They would have to run after the node migrations (d6_node:*, d7_node:*, and their ilk), which we can accomplish using the existing migration dependency system. They could easily loop through all entity reference fields, and then simply use the migration_lookup plugin to adjust the value.
Remaining tasks
Write the test and patch
Test it some more
Commit it!
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #35 | 2912353-35.patch | 28.78 KB | alexpott |
| #35 | 32-35-interdiff.txt | 3.39 KB | alexpott |
| #32 | interdiff-2912353-29-32.txt | 5.19 KB | maxocub |
| #32 | 2912353-32.patch | 28.57 KB | maxocub |
Comments
Comment #2
maxocub commentedTagging.
Comment #3
heddnSoft postponing on #2912348: Handle entity_references related to Drupal 6 and 7 node translations with different IDs while we figure out a plan of action.
Comment #5
maxocub commentedI started to look at this to see if what we are doing in #2912348: Handle entity_references related to Drupal 6 and 7 node translations with different IDs will help here.
For the entity reference field, the non-existent IDs were migrated into the field so it is possible to run a follow-up migration to update them with the right IDs.
But in the menu_items migration, we validate that the paths exists, so the paths pointing to non-existent nodes do not get migrated and we can't have a follow-up migration to update them.
I will try to see what we can do to fix that or if we will need a different solution here.
Comment #6
maxocub commentedWhen #2912348: Handle entity_references related to Drupal 6 and 7 node translations with different IDs lands, here's a first POC to work with.
Comment #7
maxocub commentedIn fact, this issue doesn't need to be postponed on #2912348: Handle entity_references related to Drupal 6 and 7 node translations with different IDs. The problem we had with entity reference fields was that they needed a migration to be derived after all other migrations, so we came up with the idea of follow-up migrations.
But here, there's no need for a derived migration so we can add a new normal migration, making sure it will run at the right time by using the existing migration dependencies system.
I will add tests in the next few days.
Comment #8
maxocub commentedHere's tests for D6 and D7.
Comment #9
maxocub commentedThe previous patch will fail, I forgot to update the entity counts, as always.
Comment #12
maxocub commentedFixed the tests and renamed the migration to node_translation_menu_links.
Comment #14
maxocub commentedOups, forgot to update the tests with the new migration ID.
Comment #15
phenaproximaI think this is really fantastic work. Wow! Great job, everyone. I have only a few things to complain about, hopefully all relatively minor.
We're also looking in d6_node_translation :)
This process pipeline is complex and opaque. I think we should add a big comment here to extensively document what is expected to happen at every stage of this transformation.
This should probably have a $ anchor at the end.
I wonder if it might not be preferable to use str_replace() or regex capture here.
Doesn't this sort of establish a hard testing dependency on Node?
All of this should be assertSame().
Comment #16
maxocub commented@phenaproxima: Thanks for the review, I'm on it.
Comment #17
maxocub commentedComment #18
heddnNit: This can combine into a single line.
Be more assertive. "Isolate the node ID."
Extract node ID. We use 0 because...? Why do we use zero? That's a question I don't know the answer to. But comments that explain why are usually better than ones that explain what is going on here.
Skip row if node ID is empty.
Nit: "to find the new node ID." We can drop the words "try to".
Skip row if the new node ID is empty.
Can this combine into a single step?
This seems to be loosing functionality here. i.e. introducing a regression. What about sites that do not have i18n menus and see this situation?
Comment #19
maxocub commentedThanks for the review!
link_uriplugin expects an array, that's why it's on a new line. We could also dosource: [link_path]but I prefer the new line.link_pathvalue is used in two processes below,link/uri&route.translationsorkeep_unrouted_node_paths? Another way would be to write a new specialized plugin just to deal with unrouted node paths.Comment #20
maxocub commentedBack to NR.
Comment #22
maxocub commentedTests failed because now the
node_translation_menu_linksmigration does not update previously migrated menu links, but creates new ones, so it needs all the menu link properties do to so.Comment #23
heddnI see, we are doing a check on if this is a translation and ignoring things. What if we did this more generically and had a config flag to ignore checking? Something like "ignore_route_checking"
Comment #24
maxocub commentedWhat about this?
Comment #25
heddnYes, perfect. We just need to document the config option in doxygen.
Comment #26
maxocub commentedWould you be OK with a follow-up for that? There's no existing documentation on this plugin so this seems out of scope. And also we'll have to figure out and document (or fix) why the plugin expects an array and then only use the first item:
Comment #27
maxocub commentedSelf-review nits.
Comment #28
heddnre #26: absolutely, let's open a docs issue. No reason to block a critical on that. Let's add the TODO and see if there is any other feedback. But I think this is pretty close to ready now.
Comment #29
maxocub commentedFollow-up created and @todo added.
Comment #30
heddnAll feedback addressed.
Comment #31
phenaproximaLooks great!! Only found a couple of things, but I'm not sure either should block commit.
I don't like this double-negative construction; it's confusing. I'd prefer something like
validate_route: false, which would override the default value of TRUE. Is it too late to change that?Do we have an explicit, direct test of this code path in LinkUriTest?
Comment #32
maxocub commentedDone!
Comment #33
heddnThis has gone through a couple rounds of feedback. All of which is now addressed. Let's try RTBC on for size.
Comment #34
phenaproximaAgreed. +1 for RTBC.
Comment #35
alexpottNitpicky but here you are testing disabling route validation so the test method name
testRouteValidationis confusing - same with the provider. Patch attached fixes this. Leaving at RTBC because this is just a test method name change. I've also moved the doTransform() method to the bottom again. Tests pass locally - uploading to confirm they still pass on the bots.Comment #36
catchCommitted/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!
Comment #40
wim leersThis introduced problems for menu link migrations. See #2833248-8: Migrations of menu links associated with entities failing.