Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
i tried to upgrade "globalredirect" module to D6 and changed the hook_init to hook_boot, but hook_boot seems not fire at all. Simply add a _book hook to *any* module and try to add a watchdog entry, drupal_set_message, print "test" or a header() with redirect and nothing will happen at all!
Therefor it seems like hook_boot isn't working at all.
Comment | File | Size | Author |
---|---|---|---|
#16 | bootstrap_28.patch | 851 bytes | hass |
#3 | hook_boot.patch | 673 bytes | chx |
#1 | drupal_boot.patch | 559 bytes | ChrisKennedy |
Comments
Comment #1
ChrisKennedy CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: hass commentedAdditional if someone needs the language in this boot stage he cannot access this... it fires later, too
Comment #7
hass CreditAttribution: hass commentedAnother maybe (?) bad idea with the current patch could be a require_once in global redirect...
Comment #8
hass CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: chx commentedHass, if you need more stuff then just issue
drupal_bootstrap
codes 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 CreditAttribution: hass commentedI'm reopening this for a D5 backport, while chx found this bug exists in D5, too.
Comment #15
ChrisKennedy CreditAttribution: ChrisKennedy commentedInteresting... if true it's very strange that no one noticed this in D5.
Comment #16
hass CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: moshe weitzman commentedi would wait for someone to strongly care before changing D5.
Comment #20
(not verified) CreditAttribution: commentedComment #21
gpk CreditAttribution: 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.