[drupal-devel] Cache sid

Moshe Weitzman weitzman at tejasa.com
Tue Mar 1 19:24:43 UTC 2005

Julian Bond wrote:
> Julian Bond <julian_bond at voidstar.com> Tue, 1 Mar 2005 18:41:15
>> Hmmm. Maybe I shouldn't be calling functions in common.inc during the 
>> module_init hook.
>> I was trying to add a style sheet and a javascript file to the <head> 
>> of every page using quicktags_init() as an example.
> I think there may be a sequence problem here
> Index.php
> include_once 'includes/bootstrap.inc';
> drupal_page_header();
> include_once 'includes/common.inc';
> If the cache is turned on drupal_page_header() calls
> bootstrap_invoke_all('init');
> which calls
>     module_load($module);
>     module_invoke($module, $op);
> So module functions can be called before common.inc is loaded, but only 
> if cache is turned on and it's a guest user coming in. 

In this case, modules are not even loaded so surely they can't be 
called. The fact that one could call module_invoke() does not imply that 
all modules are available.

The current best practice for injecting content into <HEAD> tag is to 
use hook_menu(!$may_cache). using init is a bad idea. The developer docs 
state this but unfortuantely the vrsion which shows at drupaldocs.org is 
so old that it omits this info. I have mailed Kjartan about this.

More information about the drupal-devel mailing list