This issue has been preventing me from upgrading from a commit around October when domain stopped working with a lot of our custom multilingual work.
It took some time to finally track it down but it appears to be that the domain source module's outbound path processor gets called far too early and $options['language'] is never actually set.
The problem this causes is that on a multilingual site, when viewing an entity that has a few translations, it always defaults to looking at its default translation. If that default translation is for a different domain than the endpoint you want to look at, it redirects over to a completely different domain.
When I bumped the priority down to 90, I had to fix a few other errors that came screaming out, but I hope this works. I don't know the original reason that the priority was 200.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2973694-domain_outbound-path-processor-no-language_4.patch | 1.98 KB | Anonymous (not verified) |
| #2 | 2973694-domain_outbound-path-processor-no-language.patch | 2.13 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedvilepickle created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedComment #3
Anonymous (not verified) commentedComment #4
Anonymous (not verified) commentedDid some testing by actually implementing hook_domain_source_path_alter and realized source is passed by reference. This should fix it.
Btw for anyone passing by, implementing the following hook allows me to control paths that are non-entities to make sure the user is on the correct domain based on a language code in the path. This is important for us so we're not able to view French content on say, the US domain. I implemented a 'master request data' class in my custom module that knows what the requested language is, but it basically explodes the current path and finds the language code prefix.
Comment #5
agentrickardIs this corrected by #2940296: Combination of language negotiation and path aliasing can cause a corrupted route cache, 404s or is it a different issue?
Comment #6
agentrickardIt was originally 200 because no guidance is given for setting priority in the subscriber documentation ;-).
Comment #7
Anonymous (not verified) commentedThat issue does seem somewhat related... However it's odd that at weight 90 language becomes available compared to the current 200 weight. The linked issue makes it seem like language never gets set. But maybe it just never gets set when Domain itself needs it and something else does at a different time.
Comment #8
agentrickardOne change in the patch: We shouldn't set $source before calling the alter hook. Doing so rewrites the url to absolute, even if nothing alters the $source element. It would also be an API change.
Comment #9
agentrickardThat change broke the DomainSourceExcludeTest by forcing all URLs to be absolute, which we don't want.
Comment #10
Anonymous (not verified) commentedAh I see. Is the way around that to send active_domain to the alter hook as source? It seems like that might not work though, haven't tested it out.
I will get a chance to re-look at it in the next couple days.
Comment #11
agentrickardWell, as documented, we send NULL.
From the API point of view, the assumption is that NULL means "no source has been set, use the active domain" so passing a value seems redundant. The caller is expected to know if the URL has a canonical domain and respond accordingly.
In the case of entities, we only provide a canonical URL if the domain source field is populated.
Are you effectively saying that, as a module developer, you cannot use the hook if NULL is passed?
Comment #12
agentrickardThis has been committed in modified form as noted.