I have been working on a multisite drupal powered website for about 6 months now and everything seems working well.

Just of recent I found out that my site does not optimize urls. I mean it resolves it only to the base path and not sub-paths.

So I tried to make use of url alter module to help with sub-paths. But since domain moodule makes use of custom_url_rewrite_outbound and url alter module makes use of hook_alter, I then could not go ahead with the removal of domain module's settings_custom_url.inc file.

I have checked series of community posts and all I could find is that I have to look for a way to make custom_url_rewrite_outbound function work without conflict.

But I don't know how. Can anyone help please.

Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Cross-posts are generally frowned on.

It looks to me like it should just work with Domain Acccess rc8. Though you may have to remove lines 16-20 of DA's settings_custom_url.inc.

agentrickard’s picture

Title: Domain module versus Url alter module » Domain Access rc8
Priority: Critical » Normal

@Dave Reid

We addressed this issue in DA rc8, so I am unsure how this module now plays in. In fact, it looks like the two modules will no longer work together, since DA know checks for the precense of custom_url_rewrite_outbound() in a manner similar to url_alter.

See #450344: domain module steals custom_url_rewrite

I suppose I can change that behavior and require this module instead, but would hate to introducce the dependency at this date.

Dave Reid’s picture

Status: Active » Needs review
FileSize
7.13 KB

I've been looking into this. Here's my possible solution:

1. Set the url_alter to have a ridiculously low weight so it is the first module that is loaded in a full bootstrap. Therefore it gets to be the only module that implements the custom_url_rewrite functions.

2. Move the custom_url_rewrite_outbound stuff into domain.module so that it can be loaded after url_alter and since it is only needed on a full bootstrap (for use with url() and l()). Also remove the settings_custom_url.inc file.

Ignore the changes to settings_custom_url.inc in the patch. That file would be removed in this method.

agentrickard’s picture

We can also try this. Add these to url_alter() module. Doing so will force the module to load early enough in the bootstrap to run correctly with DA.

function url_domain_boostrap_full() {
  // Do nothing, but force our module to load.
}

function url_enable {
  domain_bootstrap_register();
}

function url_disenable {
  domain_bootstrap_unregister();
}

But even then, I would need to change the name of my function.

agentrickard’s picture

Title: Domain Access rc8 » Integrate with URL Alter module
Project: URL alter » Domain
Version: 6.x-1.0 » 6.x-2.0-rc8
Component: Miscellaneous » Code
Category: support » feature

Moving back to my queue

Dave Reid’s picture

Probably need to change the install instructions also.

agentrickard’s picture

Yes.

agentrickard’s picture

FileSize
7.4 KB

Because of how Domain Access loads, we cannot insert the !exists logic directly into the module. We have to run that check inside hook_init(), which keeps our version from loading before url_alter module's.

The attached patch tests clean, and includes new documentation. Note that I kept domain_url_rewrite_outbound() as a legacy wrapper function.

I should also note that this line of url_alter.module consistently failed for me:

function url_alter_url_alter_outbound(&$path, &$options, $original_path) {
  if ($code = url_alter_var('outbound') && !isset($_GET['url-alter-kill'])) {
    // We can not use drupal_eval() here since we need to be able to modify
    // the $result variable.
    eval($code);
  }
}

I had to remove the !isset part of the IF in order to implement stored rules for path rewrites, even when the code was valid (such as $path = 'a';).

agentrickard’s picture

Status: Needs review » Fixed
FileSize
8.21 KB

Updated patch, committed to HEAD.

Dave Reid’s picture

@agentrickard: Woot! I'll look into #8. Looking forward to figure out the next Domain Access integration problem: XML sitemap.

Status: Fixed » Closed (fixed)

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

Dave Reid’s picture

Version: 6.x-2.0-rc8 » 6.x-2.0-rc9
Status: Closed (fixed) » Needs review

Follow-up notice that I'm going to be committing a new version of the URL alter module that changes the hooks to hook_url_inbound_alter() and hook_url_outbound_alter(). This is for consistency with the hooks that were accepted into Drupal 7 (#320331: Turn custom_url_rewrite_inbound and custom_url_rewrite_outbound into hooks)!

Please update domain_url_alter_outbound() to domain_url_outbound_alter() as soon as you can since I'm creating the new URL alter release tomorrow. Plus this will make your module one-step closer to being Drupal 7 compatible (then you can even drop all the custom_url_rewrite juggling)!

agentrickard’s picture

Here's a new patch against HEAD/rc9

agentrickard’s picture

Status: Needs review » Fixed

Committed to HEAD.

Status: Fixed » Closed (fixed)

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