Links for translated content that are URL aliases get 404 errors.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | country_code-aliases.patch | 698 bytes | nedjo |
Links for translated content that are URL aliases get 404 errors.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | country_code-aliases.patch | 698 bytes | nedjo |
Comments
Comment #1
nedjoWe needed to reset
$_GET['q']after resetting the language.Attached patch appears to fix the issue.
Comment #2
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #3
zroger commentedI'm re-opening this issue since clearly there is no way that an aliased page can be properly un-aliased when using the same alias in different languages.
I think this is best illustrated by following an example request through the Drupal bootstrap process.
Lets say a request is made for /FR/about. There are 2 aliases in the system for about, one in fr-FR and one in en-US, the site default language.
Drupal Bootstrap Phases:
- DRUPAL_BOOTSTRAP_CONFIGURATION:
- DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE:
- DRUPAL_BOOTSTRAP_DATABASE:
- DRUPAL_BOOTSTRAP_ACCESS:
- DRUPAL_BOOTSTRAP_SESSION:
- these dont effect the alias process
- DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE:
- hook_boot runs here, so long as aggressive caching isn't enabled. here we init the country code to FR, but dont touch the language
- DRUPAL_BOOTSTRAP_LANGUAGE:
- drupal runs through its language handling. Since we are not using any of the default language negotiation options, the global $language gets set to either the detected browser language, or the site default language. In this case, lets say the language gets set to en-US, the site default.
- DRUPAL_BOOTSTRAP_PATH:
- the path gets un-aliased in this phase. At this point, the language is still set to en-US, so $_GET['q'] is now set to the path aliased by the en-US about alias.
- DRUPAL_BOOTSTRAP_FULL:
- this is where hook_init() runs. Only at this point do we initialize the language to fr-FR. Its too late to affect the path alias, without directly setting $_GET['q].
Seems like we have some thinking to do...
Comment #4
nedjoWe do indeed reset $_GET['q] right after we reset the language at hook_init(), which seems to solve this issue.
Comment #5
nedjoAre we getting errors? Is resetting in hook_init() too late?
Comment #6
zroger commentedYes hook_init() is too late, since DRUPAL_BOOTSTRAP_PATH comes before DRUPAL_BOOTSTRAP_FULL (where hook_init is invoke).
Maybe I should clear up that the aliases are still being normalized, just that they are normalizing to the wrong path.
Example:
- English path: biography => node/1
- French path: biography => node/2
I verified this on an install by putting a dsm() in custom_url_rewrite_inbound, that showed that when $_GET['q'] was being normalized, it was using the site's default language (en-US in my case) to do the lookup, even when browsing in French. In particular, the path being looked for was 'biography', which is in the url_alias table several times, each with different languages. $_GET['q'] is then set to the english node path, node/1.
So the following code from _country_code_init_language() runs, we are trying to get the normal path of 'node/1', not 'biography'.
We could possibly do something in custom_url_rewrite_inbound, which seems to be the logical place to put this kind of path handling. Possibly move the _country_code_init_language() call in here, so that the first time $_GET['q'] is normalized, we can fetch the correct alias src according to language.
Comment #7
nedjok, thanks, I'm following now.
The idea of moving language setting to our path rewriting indeed seems the most promising at this point.
Probably this is best done as part of #330156: Language not considered in page caching--users get wrong page. I've updated that issue (thought not with a lot of promising ideas).
Comment #8
catchThis is very closely tied to the bootstrap issue, so marking postponed against that #330156: Language not considered in page caching--users get wrong page