Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I tested migrating D6 URL aliases to D8 and /admin/config/search/path shows that URL aliases were migrated nicely. However, if I try to access a node using alias, I get Page not found. I can access the node after saving it without changing anything.
Comment | File | Size | Author |
---|---|---|---|
#38 | migrated_url_aliases-2226455-38.patch | 1.21 KB | mikeryan |
#26 | interdiff-2226455-19-26.txt | 3.23 KB | quietone |
#26 | 2226455-26.patch | 4.79 KB | quietone |
#19 | 2226455-19.patch | 4.73 KB | quietone |
#14 | interdiff.txt | 515 bytes | ultimike |
Comments
Comment #1
paulihuhtiniemi CreditAttribution: paulihuhtiniemi commentedComment #2
paulihuhtiniemi CreditAttribution: paulihuhtiniemi commentedFigured out this, issue was that URL alias had different langcode than the node.
In D6, I have content in Finnish language. In D8, I have no additional languages enabled.
All migrated node content have langcode "und" in D8, but URL aliases have langcode "fi". If I update a node, path langcode changes to "und" and alias starts to work as expected.
I think this works as designed, not sure if there's anything we could improve here?
Comment #3
mikeryanI've committed a basic work-around to the ui_poc branch:
This probably won't help the OP, but will help UI testing for now with sites where the language is empty.
A general fix should probably go into the UrlAlias destination - if the incoming langcode is empty, use the site's default, if it's present on the D8 site, pass it through, if it's present in the source but not on D8 - I guess use the D8 site's default. But, that's not granular enough - node aliases should follow the specific language of the node. Should we follow the D7 practice, and migrate entity paths as part of the entity migrations themselves? We'll then need to figure out how to identify and handle any random manual aliases not covered by those.
Comment #4
mikeryanComment #5
ultimikeComment #6
brockfanning CreditAttribution: brockfanning commented@mikeryan: This is probably a no-go because it uses CONCAT (I'm guessing that is bad for DB abstraction?) but here is a patch to maybe get the ball rolling.
Comment #7
benjy CreditAttribution: benjy commentedComment #9
ultimike@paulihuhtiniemi and/or @brockfanning,
What happens if (without the patch) after the migration is run the missing language is then enabled on D8? Do the aliases start working?
I was just chatting with Benjy about this on IRC and he suggested "if that worked, we could just throw some warnings to tell the user to enable it".
If we need to create a patch to fix it, we should start by creating a failing test. Either of you comfortable doing that?
Thanks,
-mike
Comment #10
paulihuhtiniemi CreditAttribution: paulihuhtiniemi commented- enabled Language module
- added missing language (in this case, Finnish)
At this moment URL aliases work when path prefix is used, example.com/fi/[node alias]
After that I changed Finnish to default language, made sure default language does not have path prefix and now old URL aliases work nicely.
So, adding the missing language fixes this. Some kind of warning message could be nice :)
Comment #11
benjy CreditAttribution: benjy commentedOK I added this to the known issues here: https://www.drupal.org/node/2167633
If something want's to roll a simple patch that logs a message when the language of the alias we're importing is not enabled, that would be great.
Comment #12
eliza411 CreditAttribution: eliza411 commentedI had a different, but I think closely related experience migrating a monolingual English site.
Behavior
Steps to reproduce: Language not enabled
Steps to reproduce: Language enabled
Comment #13
eliza411 CreditAttribution: eliza411 commentedFWIW, the attached patch resolved my problem. In both cases (Language enabled prior to the migration and Language NOT enabled before or after the migration) the aliases were set to English and worked
I'm leaving as Needs work, though based on the author's comments in #6
Comment #14
ultimikeI just re-rolled this patch to get things moving on this issue - it still needs work. Some notes/thoughts:
Did I miss anything here?
-mike
Comment #15
chx CreditAttribution: chx commentedWhile CONCAT is not cross sql Drupal drivers add functions to their respective databases which is supported everywhere. So in the Drupal universe using CONCAT is better than || as adding an operator is hard/impossible.
Comment #16
Gábor HojtsyI don't think this will work for sites with entity translation for example, where the node may have multiple languages, so assuming the node language should be THE path language is a no-go. (Same in Drupal 8 actually). Also a path alias without a language code is a *feature* since then it applies to all languages. If you modify that to only apply to certain languages, you are actually loosing possibly intentional setup.
Comment #17
mikeryanWhen testing #2504513: Migrate URL aliases - this is still a thing, we need to fix it. I would say, given that my vanilla D6 site loses its aliases migrating to D8, this is migrate-critical.
Comment #18
mikeryanSo, should we just use Language::LANGCODE_NOT_SPECIFIED when the incoming language is empty, rather than try to guess what the most appropriate language might be?
Comment #19
quietone CreditAttribution: quietone commentedImplemented mikeryan's suggestion of "using Language::LANGCODE_NOT_SPECIFIED when the incoming language is empty". For testing I added 2 url aliases on my test D6 site, one with an empty language and one with 'af' as the language.
Then, without enabling language module, ran a migration. Post migration the url alias for the alias that didn't original have a language set worked without having to save the node. Good. Now for the other one. I enabled the language, changed my language to 'af', and tried that alias. And got 'Page not found'. After saving the node the alias worked.
The ran a migration with all the multilingual modules installed and Afrikaans installed. The results were the same as when the language modules weren't installed.
The attached patch also has changes to MigrateUrlAliasTest because it was testing for a NotNull path when, in fact, the service returns FALSE if there is no path. Also added tests for 3 different languages instead of 1.
Without the patch bad things happen to the url_alias table. After doing the save node thing, the language field for the 'af' url alias was overwritten with 'und'.
Comment #20
quietone CreditAttribution: quietone commentedNice the patch didn't fail, but still need to fix the original problem.
Comment #21
quietone CreditAttribution: quietone commentedActually, think this is working correctly. it was me not setting up to use the second language correctly. Some more testing has convinced me this is working.
Can someone familiar with multi-lingual confirm this?
Comment #22
catchBehaviour in HEAD isn't consistent at the moment on new sites either.
Comment #23
ericpughNot sure if this is helpful, here, but I was having a similar (404 error) problem, which had nothing to do with the language settings. For me, the imported path alias had a trailing slash.
Comment #24
Finn Lewis CreditAttribution: Finn Lewis commentedI'm working on an upgrade migration from Drupal 6 to Drupall 8.0.2 using Migrate Upgrade and I have hit the issue outlined in the original post.
All the path aliases are apparently migrated correctly, but the aliases do not work and visiting a node from the /admin/content page displays the internal Drupal path like node/321.
Editing and saving the node fixes the url alias.
A quick look in the url_alias table shows that the langcode column is empty. Editing and saving the node changes this to 'und'.
I've tested the patch in #19 and re-run the upgrade migration on a fresh install, and the problem is resolved.
So the patch in #19 works for me!
- Drupal 8.0.2
- Migrate Upgrade 8.x-1.x-dev ( 2015-Dec-05)
Comment #25
benjy CreditAttribution: benjy at PreviousNext commentedIs this plugin named correctly? It seems all it does it calculate the alias language?
Comment #26
quietone CreditAttribution: quietone commentedGood point. Changed to d6_url_alias_language. Will that do or did you have something else in mind?
Comment #27
benjy CreditAttribution: benjy at PreviousNext commentedThat works for me, it could be just url_alias_language since i'm presuming this will work exactly the same for D7? Although, i've not confirmed that.
Comment #28
quietone CreditAttribution: quietone commentedI was thinking the same thing. I opted to stick with D6 until such time it was confirmed this was needed for D7.
Comment #29
benjy CreditAttribution: benjy at PreviousNext commentedOK, RTBC.
Comment #32
quietone CreditAttribution: quietone commentedNot sure why there is a failure.
Comment #33
anavarreRan into this issue. The patch in #26 looks to be working just fine.
Source (D6)
Both paths were failing with a 404 on D8 until the node got re-saved. With the patch, both paths now work as expected. Looks RTBC to me.
Comment #36
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x
I added paulihuhtiniemi, eliza411, benjy and mikeryan to issue credit but not to the commit message.
Comment #37
mikeryanOops! anavarre picked this up, there's no reason for the source value to be an array... we should be able to specify the YAML as
but the reset() complains.
Comment #38
mikeryanComment #39
catch@mikeryan would you mind opening a quick follow-up issue for that patch? Just keeps the commit history more obvious when there's 1 commit per issue. Sorry I missed that before committing.
Comment #40
mikeryan@catch: #2671946: d6_url_alias_language should accept language as a scalar opened, thanks.
Comment #41
quietone CreditAttribution: quietone as a volunteer commented