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.
Hello I am just tagging in some integration issues with globalredirect and domain access; I could use your advice what would be a good next step do i put this on an issue queue of globalredirect or domain access; Of course this can be fixed in a custom module..
On a multidomain setup of
s7.dev
children.dev
On node/2 with s7.dev as it's domain source and its only assigned domain; viewing:
So, the real issue here is that Drupal is not domain aware when it comes handling aliases, there is simply no way of Drupal to know which domain an alias belongs to, if you have multiple aliases for the same address then it will just use which ever drupal_get_path_alias(...) says it should, which is usually the most recent alias added
so in globalredirect.module, it goes to check the alias against the current URL to know if it needs to redirect..
Line 173: $alias = drupal_get_path_alias($request, $langcode);
However drupal_get_path_alias() is not domain aware either, there has been some inroads made by the domain_path module, but this is so far only working for node/%, not for other entity_types.
To complete this functionality, something somewhere needs to keep a record of which aliases are applicable to which domains, domain_path hooks a lot of CRUD hooks for aliases to record which domain it occured against, but even that is still not perfect, OTOH globalredirect MAY have to implement the same CRUD type tracking and/or integrate with the domain_path module somehow.. tricky eh?
Does using url() buy you anything here? I would think that calling url() on the path instead of manually looking up the alias might solve the issue, since Domain Access uses hook_url_rewrite_outbound().
Of course, drupal_goto() implements url(), so perhaps the problem is trying to double-check the path? Shouldn't drupal_goto() find the alias for you?
That sounds like a domain_path issue, not a core domain module issue. I don't understand how you would be getting multiple records in {url_alias}, though.
How are you inserting urls? The normal node edit form only allows for one per node. Domain Access module does not affect that, neither does Domain Path, which has its own storage.
Unless you are using Domain Path, the Domain module makes no attempt to map a URL alias to a specific domain. That should be a non-issue here.
The issue from the OP is that the canonical URL set by Domain Source module (and enforced in hook_url_rewrite_outbound()), doesn't seem to work for Global Redirect because the alias isn't being read properly.
"The issue from the OP is that the canonical URL set by Domain Source module (and enforced in hook_url_rewrite_outbound()), doesn't seem to work for Global Redirect because the alias isn't being read properly."
What is happening is global redirect through globalredirect_init() is calling drupal_alter('url_outbound', $request_path, $options, $request_path);
At the same time domain access does an alter through domain_url_outbound_alter(&$path, &$options, $original_path) and changes the base_url.
So you have situations where globalredirect is doing its job of changing the url to the path alias; and unfortunately changing the url's base path.
My propose solution would be for globalredirect to stop using drupal_alter('url_outbound', $request_path, $options, $request_path); and use another drupal api. I am sorry I don't currently have a concrete solution as to what to replace drupal_alter('url_outbound'..)
This patch should resolve the conflict between globalredirect and domain access. This is most performant solution I can see .. The patch does a check if and only if function domain_url_outbound_alter exist then unset the base_url key in the options array.. as domain_url_outbound_alter is the most likely function that is providing the key; and because global redirect scope is only the url alias and not the base_url .. this patch should fit in well..
This patch should resolve the conflict between globalredirect and domain access.
This is the most performant solution I can see ..
The patch does a check if and only if function domain_url_outbound_alter exist then unset the base_url key in the options array.. as domain_url_outbound_alter is the most likely function that is providing the key;
and because global redirect scope is only the url alias and not the base_url .. this patch should fit in well..
Comments
Comment #1
chriscalip CreditAttribution: chriscalip commentedHello I am just tagging in some integration issues with globalredirect and domain access; I could use your advice what would be a good next step do i put this on an issue queue of globalredirect or domain access; Of course this can be fixed in a custom module..
On a multidomain setup of
s7.dev
children.dev
On node/2 with s7.dev as it's domain source and its only assigned domain; viewing:
http://children.dev/node/2 gets rightly redirect to http://s7.dev/node/2
But viewing it on node 2's alias of (node-2-alias) :
http://children.dev/node-2-alias does not get redirect to http://s7.dev/node/2
Comment #2
agentrickardGlobal redirect. We've had longstanding issues with that module being overly aggressive.
Comment #3
carsonblack CreditAttribution: carsonblack commentedSorry agentrickard, which module are you saying is overly agressive?
Comment #4
agentrickardGlobal Redirect. DA never issues these types of redirects.
Comment #5
dgtlmoon CreditAttribution: dgtlmoon commentedSo, the real issue here is that Drupal is not domain aware when it comes handling aliases, there is simply no way of Drupal to know which domain an alias belongs to, if you have multiple aliases for the same address then it will just use which ever drupal_get_path_alias(...) says it should, which is usually the most recent alias added
so in globalredirect.module, it goes to check the alias against the current URL to know if it needs to redirect..
Line 173: $alias = drupal_get_path_alias($request, $langcode);
However drupal_get_path_alias() is not domain aware either, there has been some inroads made by the domain_path module, but this is so far only working for node/%, not for other entity_types.
To complete this functionality, something somewhere needs to keep a record of which aliases are applicable to which domains, domain_path hooks a lot of CRUD hooks for aliases to record which domain it occured against, but even that is still not perfect, OTOH globalredirect MAY have to implement the same CRUD type tracking and/or integrate with the domain_path module somehow.. tricky eh?
Comment #6
agentrickardDoes using url() buy you anything here? I would think that calling url() on the path instead of manually looking up the alias might solve the issue, since Domain Access uses hook_url_rewrite_outbound().
Of course, drupal_goto() implements url(), so perhaps the problem is trying to double-check the path? Shouldn't drupal_goto() find the alias for you?
Comment #7
dgtlmoon CreditAttribution: dgtlmoon commented@agentrickard nah, because it's still not possible to know what alias and path is for which domain, theres simply no record of it
Until something works out, we're turning off globalredirect in this situation with the following patch, hope it helps someone out there!
Comment #8
agentrickardThat sounds like a domain_path issue, not a core domain module issue. I don't understand how you would be getting multiple records in {url_alias}, though.
Comment #9
dgtlmoon CreditAttribution: dgtlmoon commenteddomain is not core, and you can reproduce this issue without domain_path, try it, you can insert as many aliases into url_alias as you like too
Comment #10
agentrickard"core domain" == the Domain Access main module.
How are you inserting urls? The normal node edit form only allows for one per node. Domain Access module does not affect that, neither does Domain Path, which has its own storage.
Comment #11
agentrickardLet me be more clear:
Unless you are using Domain Path, the Domain module makes no attempt to map a URL alias to a specific domain. That should be a non-issue here.
The issue from the OP is that the canonical URL set by Domain Source module (and enforced in hook_url_rewrite_outbound()), doesn't seem to work for Global Redirect because the alias isn't being read properly.
Comment #12
pwiniacki CreditAttribution: pwiniacki commentedpossibly related topics:
https://www.drupal.org/node/1411704
https://www.drupal.org/node/1540064
https://www.drupal.org/node/1524326
https://www.drupal.org/node/1215134
https://www.drupal.org/node/1647016
https://www.drupal.org/node/1526408
https://www.drupal.org/node/707168
plz edit/let me know, if you see something not important/related.
Comment #13
chriscalip CreditAttribution: chriscalip commentedIn response to #11
"The issue from the OP is that the canonical URL set by Domain Source module (and enforced in hook_url_rewrite_outbound()), doesn't seem to work for Global Redirect because the alias isn't being read properly."
What is happening is global redirect through globalredirect_init() is calling drupal_alter('url_outbound', $request_path, $options, $request_path);
At the same time domain access does an alter through domain_url_outbound_alter(&$path, &$options, $original_path) and changes the base_url.
So you have situations where globalredirect is doing its job of changing the url to the path alias; and unfortunately changing the url's base path.
My propose solution would be for globalredirect to stop using drupal_alter('url_outbound', $request_path, $options, $request_path); and use another drupal api. I am sorry I don't currently have a concrete solution as to what to replace drupal_alter('url_outbound'..)
Comment #14
chriscalip CreditAttribution: chriscalip commentedThis patch should resolve the conflict between globalredirect and domain access. This is most performant solution I can see .. The patch does a check if and only if function domain_url_outbound_alter exist then unset the base_url key in the options array.. as domain_url_outbound_alter is the most likely function that is providing the key; and because global redirect scope is only the url alias and not the base_url .. this patch should fit in well..
Comment #15
chriscalip CreditAttribution: chriscalip commentedComment #16
chriscalip CreditAttribution: chriscalip commentedpatch needs more work.
Comment #17
chriscalip CreditAttribution: chriscalip commentedThis patch should resolve the conflict between globalredirect and domain access.
This is the most performant solution I can see ..
The patch does a check if and only if function domain_url_outbound_alter exist then unset the base_url key in the options array.. as domain_url_outbound_alter is the most likely function that is providing the key;
and because global redirect scope is only the url alias and not the base_url .. this patch should fit in well..
Comment #18
chriscalip CreditAttribution: chriscalip commentedComment #19
Chris Matthews CreditAttribution: Chris Matthews commentedThe 3 year old patch in #17 to globalredirect.module applied cleanly to the latest 7.x-1.x-dev, but still needs community review & testing.
Comment #20
dunx CreditAttribution: dunx commentedThe patch doesn't resolve the (possibly related) issue with domain_path mentioned here
https://www.drupal.org/project/domain_path/issues/1325088