This has got me very confused. If I have a url alias of 'contact' for node/5, then when I go to node/5 and globalredirect kicks in to take me to 'contact', I get a "Call to undefined function trace_hook()" in trace.module on line 124, which is the call in hook_exit. This is even weirder, because I have tracing disabled.

On closer inspection, it turned out that TRACE_ACTIVE, and TRACE_HOOKS were not even defined yet. Here is a backtrace at the start of hook_exit.

#0 trace_exit(/contact)
#1 call_user_func_array(trace_exit, Array ([1] => /contact)) called at [/includes/module.inc:471]
#2 module_invoke_all(exit, /contact) called at [/includes/common.inc:312]
#3 drupal_goto(contact-us, , , 301) called at [/modules/globalredirect/globalredirect.module:83]
#4 globalredirect_init()
#5 call_user_func_array(globalredirect_init, Array ()) called at [/includes/module.inc:471]
#6 module_invoke_all(init) called at [/includes/common.inc:2463]
#7 _drupal_bootstrap_full() called at [/includes/bootstrap.inc:1022]
#8 _drupal_bootstrap(8) called at [/includes/bootstrap.inc:933]
#9 drupal_bootstrap(8) called at [/modules/trace/trace.module:17]
#10 include_once(/modules/trace/trace.module) called at [/includes/bootstrap.inc:563]
#11 drupal_load(module, trace) called at [/includes/bootstrap.inc:536]
#12 bootstrap_invoke_all(boot) called at [/includes/bootstrap.inc:994]
#13 _drupal_bootstrap(5) called at [/includes/bootstrap.inc:933]
#14 drupal_bootstrap(8) called at [/index.php:16]

After looking at that, I can see what is happening, but I would have no idea on the best approach for fixing it. It would seem that the trace module calling the bootstrap, which includes all the hook_init calls, but the globalredirect hook_init calls a drupal_goto, which calls hook_exit, but when hook_exit is called here, none of the trace variables are defined yet. Perhaps a solution would be check if TRACE_ACTIVE is defined, and not do anything if it is not?

Comments

Justin Miller’s picture

Assigned: Unassigned » Justin Miller

Thanks for the feedback. I have not tested Trace with Global Redirect yet, so I will look into this.

EvanDonovan’s picture

Any progress on this issue? I can confirm it is occurring for me on Global Redirect pages also.

Arto’s picture

Component: Code » Compatibility
Status: Active » Fixed
Issue tags: +trace_hook, +Global Redirect

Never had this problem myself, but this was probably related to special cases in Drupal's bootstrap vis-a-vis Global Redirect.

The recent 6.x-1.0 release should solve this problem by moving the trace_hook() function into the main module (instead of having it in an include file), which means that the function in question will always be available regardless of the bootstrap context.

Arto’s picture

Title: Trace & Globalredirect issues. » Issue with Global Redirect pages
EvanDonovan’s picture

Thanks. I'll test Trace again soon as part of a new round of performance optimizations on my site.

Status: Fixed » Closed (fixed)
Issue tags: -trace_hook, -Global Redirect

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