Closed (duplicate)
Project:
Drupal core
Version:
6.x-dev
Component:
theme system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Mar 2009 at 02:03 UTC
Updated:
5 Jun 2011 at 11:42 UTC
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
Comment #1
moshe weitzman commentedOne way or another, this needs solving. Your idea sounds reasonable.
Comment #2
David_Rothstein commentedIn 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 :)
Comment #3
Jeremy Byrne commentedI'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.
Comment #4
donquixote commentedinteresting. subscribe. related with this one,
#553944: Define hook_menu_get_item_alter() as a reliable hook that runs before the page is doomed
Comment #5
damien tournoud commentedDuplicate of #219910: Calling theme function from hook_init() interferes with administration theme.