Drupal Bootstrap - Request Processing in Drupal
In this blog post I try
to list the sequence of steps Drupal 5 takes to process an HTTP request.
I have not seen it all put together in any one place. I do, however,
believe that understanding the request life-cycle is crucial to grasping
how a web-system works, so I hope this post will be useful to some
people.
Drupal 5 uses a mechanism it calls Bootstrapping, to process an HTTP request. It is so complex that a book can easily be written about it, but that is obviously not my purpose. Therefore, I try to be laconic and concentrate on making the “diagram” rather expressive than detailed.
Disclaimer: inline comments from Drupal source code were used to compile this text.
- index.php
- bootstrap.inc:
- drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE); - non-database cache.
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_ACCESS); - identify and reject banned hosts.
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE); - start the variable system and try to serve a page from the cache.
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); - set $_GET[‘q’] to Drupal path of request
- _drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
- common.inc->_drupal_bootstrap_full();
- drupal_set_header(‘Content-Type: text/html; charset=utf-8’); - hard-coded!
- unicode_check();
- fix_gpc_magic(); - undo magic quotes
- module_load_all();
- locale_initialize(); - initialize the localization system. Depends on i18n.module being loaded already
- module_invoke_all(‘init’);
- menu.inc -> menu_execute_active_handler();
via menu_get_menu() - going through the menu hooks of all modules, determines the callback function registered to process current URI and delegates to it, or returns either MENU_ACCESS_DENIED or MENU_NOT_FOUND.
- theme.inc -> theme(‘page’, $return); - wraps the output of the callback function into a page-wide theme.