I installed and activated url_alter and subpath_alias and I've written a simple module that implements the hooks and does nothing but write into the log via watchdog.

What happens is that that the outbound hook is called and the inbound hook is not. I see this in the log report and I see this in the debugger.

debugging url_alter function custom_url_rewrite_inbound shows that only the implementation in url_alter itself is called. And only sometimes the subpath_alias implementation.

I can think of two possible reasons:
1. I'm too silly to type the name of the hook. Possible, but I've checked a hundred times and subpath_alias shows the same problem in the debugger.
2. the url_alter function custom_url_rewrite_inbound is called very early when my function is not loaded yet.

What can I do about the second possible cause? Any idea?

This is Drupal 6.19 on MAMP debugged with XDebug and Eclipse on Mac OS X 10.6

Comments

GerdC’s picture

Title: inbound hook not called » inbound hook not called if feedburner is installed
Category: support » bug
Priority: Normal » Major
Status: Active » Needs work

So this is what I found out:

in feedburner.install there is a line db_query("UPDATE {system} SET weight = -1 WHERE type = 'module' AND name = 'feedburner'");

which means a boot sequence (in my installation)
1. url_alter
2. feedburner
3. everything else

the thing feedburner does in the boot sequence is:

/**
* Implementation of hook_boot().
*/
function feedburner_boot() {
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
$path = _feedburner_get_path_segment();
feedburner_check_redirect($path);
}

feedburner changes the bootstrap sequence (which I think a module should not do) and makes calls that call url_alter. custom_url_rewrite_inbound very early in the boot hook, when other modules like mine and subpath_alias are not loaded.

Next thing that happens is that url_alter. custom_url_rewrite_inbound calls module_implements('url_inbound_alter') which determines the implementations of the hook AND CACHES THE RESULT.

So even later, when url_alter. custom_url_rewrite_inbound is called again and again (and more modules are loaded, including those that implement url_alter's hooks), this old cache is used, so the inbound hooks are never called.

feedburner does not touch outbound paths in the boot process, so the outbound hooks work fine.

GerdC’s picture

This workaround fixed it for my module:

write a mymodule.install that contains a install hook like the one in url_alter: (replace mymodule by your module name)

/**
* Implementation of hook_install().
*/
function mymodule_install() {
db_query("UPDATE {system} SET weight = -1000 WHERE type = 'module' AND name = 'mymodule'");
}

and be sure that you make a new install.
Even if you do this: if you use the feedburner module, you might not have many modules to call since feedburner calls your hook before (m)any contrib modules are loaded.

Should this be a recommendation for modules, that use url_alter?

Gerd