Right now when I enable Domain Path it appears that Global Redirect stops working, is there any way to get the 2 to play nice with each other?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Status: Active » Postponed (maintainer needs more info)
codewatson’s picture

Ok well for more info, with Global Redirect 7.x-1.5, any request to a node is supposed to go to its alias, so if you make a request to "node/1" it should redirect to node 1's alias, lets say "foo-bar" for example. However when you enable Domain Path 7.x-1.0-beta3 this stops happening, going to "node/1" does not redirect to "foo-bar" and instead stays on "node/1" (default drupal behavior).

Is this some sort of conflict between the modules? Is there a configuration for domain path I missed? I tried playing with the module weights to see if that made any difference but no luck.

codewatson’s picture

Did some debugging, line 80 of globalredirect.module preforms:

drupal_alter('url_outbound', $request_path, $options, $request_path);

$request_path before the alter is set to "node/1", and after is still "node/1".

Later it does another url_outbound to get the alias, line 194:

drupal_alter('url_outbound', $alias, $options, $current_path);

$alias is set to "foo-bar"

Then on line 217 it compares $request_path to $alias to see if they are different, if they are, then it performs the redirect to the alias.

From what i can tell that first url_outbound for $request_path is being changed by Domain Path, so before it is set to "node/1", and after it is set to "foo-bar" which means later when it compares $request_path with $alias, they are the same so it doesn't perform a redirect, however that still leaves you sitting on "node/1" and you are not actually at "foo-bar".

I poked around in domain_path.module and narrowed it down to this section starting at line 49:

  if (isset($paths[$domain_id])) {
    $path = $paths[$domain_id];
  }
  else {
    $path = drupal_get_path_alias($alias);
  }
 

If I comment out that section, then global redirect works correctly, though it only redirects to the default drupal path alias, not the one set by Domain Path.

Not sure what to do about it, somehow Domain Path needs to change just the alias, not the original request?

apemantus’s picture

I've just run into this issue running the latest dev version of Domain Path and latest version of Global Redirect. In my case, paths set using Domain Path don't work, sending the browser into an infinite loop.

My quick and easy (but somewhat hacky?) workout around is to add $_POST['domain_path'] = TRUE to urls set by Domain Path as Global Redirect doesn't run if there's anything set in $_POST. I guess I should add in a check just on the off-chance somebody is POSTing a variable called domain_path. So:

function domain_path_url_inbound_alter(&$path, $original_path, $path_language) {
  if ($source = domain_path_lookup_path('source', $original_path, NULL, $path_language)) {
    if (empty($_POST)) {
      $_POST['domain_path'] = TRUE;
    }
    $path = $source;
  }
}
agentrickard’s picture

Status: Postponed (maintainer needs more info) » Active
batigol’s picture

http://drupal.org/node/1540064 (#3)

It seems to be related.

rudiedirkx’s picture

I'm experiencing the same as @dwatson (and #1411704: Conflict with Domain Access as domain_url_outbound_alter() returns alias). I don't want redirection to another domain, but to another path (the alias). The url_outbound alter in globalredirect messes that up for ALL aliases.

It's not the same issue as #1540064: Redirects between two domains is not working IMO.

I expected the Domain Path aliases to NOT work with Global Redirect (acceptable), but this is somewhat disappointing.

I still don't understand why Global Redirect does that url_outbound alter on the incoming path... Obviously it's changed to an alias... That's what modules do.

rudiedirkx’s picture

@apemantus I'm not experiencing any redirect loops by the way... How did that happen?

rimen’s picture

Assigned: Unassigned » rimen
Status: Active » Needs review
FileSize
2.5 KB

I have the same problems with redirect loops for domain_path aliases.
Error occured in domain_path_lookup_path(). This function cache alias paths and source path in single place - $cache['map'] so that a wrong alias is returned for given source if there is cached info.
Patch attached.

agentrickard’s picture

Category: feature » bug

That looks good on quick review.

rimen’s picture

Status: Needs review » Needs work

Not work redirect from system path to alias

rimen’s picture

The reasons are described here http://drupal.org/node/1411704. (hook_url_outbound_alter invoked twice and we need to return domain alias only on the second call)

If patch globalredirect as I described here http://drupal.org/node/1411704#comment-6968340 than we can check the second invocation of hook_url_outbound_alter in domain_path_domain_path()

/**
 * Implements hook_domainpath().
 */
function domain_path_domain_path($domain_id, &$path, &$options, $original_path) {
  // Let's not muck with absolute paths.
  if (!empty($options['absolute'])) {
    return;
  }
  
  /* Globalredirect support
   * Check that hook_url_outbound_alter() invoked by globalredirect and determine the second invocation
   */
  if (isset($options['globalredirect']) && empty($options['globalredirect_domain_path'])){
    $options['globalredirect_domain_path'] = TRUE;
    return $path;
  }
  ...

So that we return domain alias only on the second url rewriting and globalredirect work correctly

rimen’s picture

Status: Needs work » Needs review
grndlvl’s picture

Seems reasonable as long as the patch is accepted for globalredirect.

Is #9 addressing a separate issue? The attached patch seemed to work as expected without it.

rimen’s picture

#9 is the same issue and it decide problem with redirect loops (it is domain_path bug). But redirecting not work (see #11, #12)
Your patch (based on #12) will not have any effect on non patched globalredirect because $options['globalredirect'] is not set always

rimen’s picture

May be we must patch domain module that implements hook_url_outbound_alter to prevent extra hook_domain_path invocation

grndlvl’s picture

Is #9 addressing a separate issue? The attached patch seemed to work as expected without it.

So the solution with the patch from 14 and globalredirect. Does that fix the original issue alone? If not how can we reproduce. I had tested the "Non-clean to Clean" functionality. Apologies if I am missing something.

Your patch (based on #12) will not have any effect on non patched globalredirect because $options['globalredirect'] is not set always

Seems to be a fair assessment. I was stating I would rather be sure that the patch was committed to globalredirect before committing to domain_path.

rimen’s picture

I'm sorry, perhaps I did not understand you correctly. And sorry for my terrible english )
Yes, #9 seems as separate issue but for me and some others it cause infinite loop redirecting with globalredirect.

I agree, that solution for this issue with the patch from 14 and globalredirect patch
But #9 seems as bug also

grndlvl’s picture

In response to #11 there is actually a ticket to add system paths to the white list #1493144: Implement whitelist as in drupal_lookup_path to prevent unecessary lookups so that should be fixed once that is implemented.

anydigital’s picture

Issue summary: View changes

Checkout this module: https://www.drupal.org/project/domain_path_rewrite

Every internal path will be automagically redirected to the related domain path with it.

anydigital’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.