When you set the option "Use active domain" on a node with Domain Source submodule, the request get a redirect (302) to an empty domain.
Ex:
1) You set "Use active domain" option as source domain in node id 123
2) You open the following URL in your browser http://subdomain.mydomain.com/node/123
Observed behavior:
You get a 302 redirection to http:///node/123
Expected behavior:
Stay on current domain so stay on http://subdomain.mydomain.com/node/123
The cause of the issue:
domain_source_domain_source_alter() in domain_source.domain.inc does a domain_lookup($source_id) with $source_id = -5 (DOMAIN_SOURCE_USE_ACTIVE constant value):
// The source_id always returns a valid domain.
$source = domain_lookup($source_id);
But domain_lookup returns -1 because it does:
if ((is_null($domain_id) && is_null($subdomain)) || ($domain_id < 0) {
$domains[$key] = -1;
}
While domain_source_domain_source_alter() expects it to return -5 in that case as after the domain_lookup it does:
// DOMAIN_SOURCE_USE_ACTIVE is the status for 'Use active domain.'
if ($source == DOMAIN_SOURCE_USE_ACTIVE) {
$source = domain_get_domain();
}
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1934880-domain-source-lookup.patch | 2.54 KB | agentrickard |
| #3 | domain-7.x-3.9-fix-use-active-domain-1934880-2.patch | 536 bytes | bpresles |
| #1 | domain-7.x-3.9-fix-use-active-domain-1934880-1.patch | 1.25 KB | bpresles |
Comments
Comment #1
bpresles commentedProposed patch attached
Comment #2
bpresles commentedComment #3
bpresles commentedAfter further investigation, it seems to be caused by commit 891b5f88517f2a0602438b276cea8a90fa3bc56c related to issue #1864922 (http://drupal.org/node/1864922)
Attached a simpler patch
Comment #4
agentrickardI don't think "redirect" is the proper term here. Domain Source doesn't issue redirects; it rewrites URLs.
Please clarify. Are you using some other module that issues the redirect?
Comment #5
agentrickardI agree, however. That logic is not right. This seems more accurate:
This needs a proper test.
Comment #6
agentrickardHere's a patch, but the current tests don't fail like I would like if the new logic is reverted.
Comment #7
bpresles commentedIndeed, redirecting is the wrong word, it's indeed just rewriting.
Comment #8
agentrickardDoes the patch fix it?
Comment #9
agentrickardCommitted.
Comment #10
bpresles commentedYes the patch fix it. Thanks. (and sorry for the delay)