I need to run some hooks very early in the boostrap like enhanced_page_cache does.

I copied the same hook_update to set my module as available in Drupal bootstrap and alter its weight.

 * Ensure the weight of the module is pretty high.
 function MYMODULE_update_7000() {
   // Make sure this module is available on bootstrap.
    ->fields(array('bootstrap' => 1, 'weight' => 98))
    ->condition('type', 'module')
    ->condition('name', 'MYMODULE')

After the update the values are there, but if the caches are cleared, the module's bootstrap value on system table reverts back to 0.

Why is this happening?

How does the Enhanced_page_cache module does it and keeps the value intact?

Do i forget something?


  • Is it possible, that your module declares dependencies to other modules and that therefor the weight of your custom module is reset automatically to run after the modules that you depend on? – berliner Jan 28 '14 at 11:27
  • the weight is set correctly, the bootstrap value get reverted, check my answer, think i found it!, thanks! – Pan Chrono Jan 28 '14 at 12:03

ok got it,

in system.module there is a function called _system_update_bootstrap_status()

this function changes bootstrap value to '1' for all modules that implement one (or more) of the hooks: 'boot', 'exit', 'watchdog', 'language_init'

so i just needed to implement an empty hook_boot() and my module is present in bootstrap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.