Thanks for a great module, unfortunately I can't use it on my site because I am using the Subdomain module. Subdomain lets you extend path aliases to subdomains, and it does it using a neat trick: if you enter an alias like this: ~blog/entry, the path gets rewritten to look like this: http://blog.mysite.com/entry. So the tilde character has the special property of setting the subdomain for a path.
Anyway, when I enabled this module I discovered that sub-path aliases don't respect the special properties of the tilde, so clicking on the edit tab in the above example would take you to http://mysite.com/~blog/entry/edit instead of http://blog.mysite.com/entry/edit.
Any chance this could be fixed?
Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

John Morahan’s picture

If you decrease the weight of subpath_alias so that it runs before subdomain, that works for outbound URLs.

It doesn't work for inbound URLs because of this code in subpath_alias_url_inbound_alter():

    // Special case where the full path was already matched by
    // drupal_lookup_path(). Add to $map to avoid unnecessary future lookups.
    if ($path != $original_path) {
      $map[$path_language][$path] = $original_path;
      return;
    }

Commenting out that code seems to work. But I'm not sure what the consequences of removing this case might be (guessing a performance hit, from the comment).

smk-ka’s picture

Good catch, thank you!

But I'm not sure what the consequences of removing this case might be (guessing a performance hit, from the comment).

That's right, it's purely performance related and can be nuked if we gain better compatibility. Could you create a patch based on the findings?

John Morahan’s picture

Status: Active » Needs work
FileSize
1.3 KB

Hmm.

Well, here's the patch. But on further investigation it doesn't totally clear things up. Outbound paths are not rewritten correctly on a subdomain front page, and I don't know why.

John Morahan’s picture

Status: Needs work » Needs review
FileSize
1.75 KB

In subpath_alias_url_outbound_alter():

      // Add subpath, except we already know there is no mapping.
      if (!isset($map[$path_language][$subpath]) || $map[$path_language][$subpath] !== FALSE) {
        $args[] = $subpath;
      }

If you remove the 'if' and unconditionally add the subpath to $args, it works.

But why does it think it 'knows' there is no mapping in this case?

Patch attached, in case you think it makes sense...

colemanw’s picture

@smk-ka & John Morahan

I think you can keep the performance gain and just opt-out subdomain users, like so:

<?php
    // Special case where the full path was already matched by
    // drupal_lookup_path(). Add to $map to avoid unnecessary future lookups.
    // Incompatible with subdomain module.
    if ( ($path != $original_path) && !(module_exists('subdomain')) ) {
      $map[$path_language][$path] = $original_path;
      return;
    }
?>