Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
base system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Aug 2007 at 19:12 UTC
Updated:
19 Oct 2008 at 22:56 UTC
Jump to comment: Most recent file
Comments
Comment #1
ChrisKennedy commentedWell, hook_boot() is currently only run if serving a normally cached page. Attached is a patch to run it on a full bootstrap also. Do we want it to run under aggressive caching?
Comment #2
ChrisKennedy commentedWhile researching this issue I also noticed that hook_boot never got added to http://api.drupal.org/api/group/hooks/6 and the hook_init documentation was not updated to explain that it's only for non-cached pages.
Comment #3
chx commentedFunny thing is, hook_init had the same probs in D5. But your soluition is not right, boot should fire sooner.
Comment #4
hass commentedChris: hook_boot should run like hook_init in D5. This means hook_boot will not fire in aggressive caching mode.
Comment #5
hass commented@chx: now, boot fires, but the
function_exists('drupal_get_path_alias')gives "false"... and path lookup doesn't work in this level. If this will be the final patch i need to duplicate much Drupal Core function in the module. This maybe faster - but not very cool from the api side. Isn't there a better way? e.g. fire at DRUPAL_BOOTSTRAP_FULL, when every function is accessible?Comment #6
hass commentedAdditional if someone needs the language in this boot stage he cannot access this... it fires later, too
Comment #7
hass commentedAnother maybe (?) bad idea with the current patch could be a require_once in global redirect...
Comment #8
hass commentedmajor correction... i need to rebuild the complete DRUPAL_BOOTSTRAP_PATH in global_redirect module.
Comment #9
gábor hojtsyYeah, I asked people to update the docs, there is still an open issue about it. Also, hass you should rethink whether you really should use hook_boot and not hook_init.
Comment #10
hass commentedWell, i think you are talking about my case http://drupal.org/node/161136.
I thought about moving to hook_init, but this hook doesn't fire on cached pages - isn't it? But global redirect need to run earlier and every time, while we must redirect for e.g. from "node/1" to the appropriate url alias - if one exists. This redirect need to be invoked for cached and non cached pages and this requires hook_boot as i understand :-(((.
Aside it would be a great deal if this small piece of code (global redirect) will be integrated into core to get rid of duplicate content without any extra modules... so we don't need to care of all the above problem at all.
Comment #11
gábor hojtsyHass, the whole point of caching is not to load/call a lot of functionality in the page! So it is a feature if code is not run there. And the other point of caching is that one needs to decide early, so the cached requests are very light. It does not seem there is a clean way for you.
Comment #12
chx commentedHass, if you need more stuff then just issue
drupal_bootstrapcodes to more advanced levels, like DRUPAL_BOOTSTRAP_PATH or _FULL .Comment #13
gábor hojtsyOK, the hook_boot call moving is done, comitted. Thanks. (Please document in the update docs! I know we have some issue open for this, so I am not leaving this one open).
Comment #14
hass commentedI'm reopening this for a D5 backport, while chx found this bug exists in D5, too.
Comment #15
ChrisKennedy commentedInteresting... if true it's very strange that no one noticed this in D5.
Comment #16
hass commentedD5 patch attached
Comment #17
drummI am hesitant to move around hook calling in Drupal 5.x, which is in maintenance mode. Can anyone think of any way this might negatively affect modules which currently use hook_init()?
Comment #18
hass commentedWell, i think it changes some important things and will break some modules like global_redirect. I'm not sure if the patch is correct, so please review carefully. And we don't have a hook_boot... maybe it's better to stay as is... i change this only after chx said this problem is inside D5, too. not sure if this is fixed by the patch correctly, while i'm not so deep inside bootstrap part.
Comment #19
moshe weitzman commentedi would wait for someone to strongly care before changing D5.
Comment #20
(not verified) commentedComment #21
gpk commentedFor the record, in 5.x hook_init() *is* invoked on uncached page views, in http://api.drupal.org/api/function/_drupal_bootstrap_full/5.
The difference for hook_init() as far as cached vs. uncached page views is that on an uncached page view the init hook is invoked right at the end of the bootstrap (so Drupal is fully loaded), whereas for a cached page view it is invoked during DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE phase, so most of Drupal has not been loaded yet.
This is why hook_init() was split into hook_boot() [invoked during DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE *for both cached and uncached page views*] and hook_init() [invoked at end of bootstrap, uncached page views only], in 6.x.
Resetting title and version.