4

In my custom module, I use a hook_init() with a dpm-function.

function mymodule_init() {
    dpm('check');
}

but for some reason, my page shows 2 times 'check' on the page... Is this default Drupal behavior? And if so, what are the reason for this behavior?

  • it should appear only once, cleared cache? Try this way and see what happends? drupal_set_message("check",'ok', false); – Vimalnath Jun 26 '13 at 8:05
  • Ofcourse with the false parameter, the message shows only once. But I would like to know why the message is showing twice even though it only should appear once in hook_init() – Michiel Jun 26 '13 at 8:19
  • This answer from this question drupal.stackexchange.com/questions/36265/… should be able to answer your question. – 4life Jun 26 '13 at 8:36
4

hook_init runs once per-page request, for non-cached pages.

See _drupal_bootstrap_full

module_invoke_all('init');

I guess what's perhaps happening in your case is an additional ajax request is bootstrapping Drupal and triggering an additional hook_init call.

| improve this answer | |
  • 3
    I believe this is often the case with admin menu. – Letharion Jun 26 '13 at 8:58
  • 1
    Could also be a 404 from a linked asset on the page. – mpdonadio Jun 26 '13 at 10:16

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.