It seem touching the theme system in hook_init() is a no-no that can cause all kinds of problems: #374645: Site off-line page is un-themed

To eliminated this problem, how about not including the file theme.inc until after hook_init() are invoked in _drupal_bootstrap_full()? Or make init_theme() fail if it's called at the wrong time?

As is now, there is nothing to prevent this and the problems this causes are very mysterious.

Comments

moshe weitzman’s picture

Priority: Normal » Critical

One way or another, this needs solving. Your idea sounds reasonable.

David_Rothstein’s picture

Version: 6.10 » 6.x-dev

In Drupal 7, calling theme functions from hook_init() is expected to work - #374645: Site off-line page is un-themed appears to be a bug that is still there, but that's the only one I know of, and it should be possible to fix.

In Drupal 6 - which this issue is filed against - yeah, it's a total mess :)

Jeremy Byrne’s picture

I'm currently experiencing a problem apparently related to this issue on a production site (running 6.12).

Specifically, cron.php is failing with "include_once(./[MODULE_PATH]/[MODULE_NAME]/[MODULE_NAME].theme.inc) [function.include-once]: failed to open stream: No such file or directory in /[BASE_PATH]/[MODULE_PATH]/[MODULE_NAME]/[MODULE_NAME].module on line [X]." style errors. If I hack [MODULE_NAME].module to hard-code the path to the .theme.inc file, the error simply occurs in the next module in the chain which includes a .theme.inc. (I guess I could hard-code the path for all modules, but that hardly seems a good solution.)

"[N]ot including the file theme.inc until after hook_init() are invoked in _drupal_bootstrap_full()" sounds like a good idea. Given it doesn't seem to have received any definitive attention in the last year or so, could you please provide some additional detail about how I might fix it myself? I'm sure the solution would be valuable to others.

donquixote’s picture

damien tournoud’s picture