Drupal 7 Line by Line Part 4 - DRUPAL_BOOTSTRAP_PAGE_CACHE
Welcome to the fourth part of the Drupal 7 Line by Line series of articles.
In this series I've been going through the Drupal page load process by going through the code line by line. So far I've covered index.php, the logic of the drupal_bootstrap function and the first bootstrap phase. (see the links at the bottom of this article if you want to catch up).
Today I'm going to cover phase two of the bootstrap process. This is where things start to get a bit more interesting as we see how Drupal handles page caching and how it supports pluggable caching backends.
Phase two starts with a call to _drupal_bootstrap_page_cache() from the drupal_bootstrap function.
_drupal_bootstrap_page_cache()
<span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #FF8000">/**<br> * Bootstrap page cache: Try to serve a page from cache.<br> */<br></span><span style="color: #007700">function </span><span style="color: #0000BB">_drupal_bootstrap_page_cache</span><span style="color: #007700">() {<br></span><span style="color: #0000BB">?></span></span>
The first thing that Drupal does is declare the global $user variable which is used throughout the page load to represent the $user which is requesting the page. At this point it is completely empty. In fact, at this stage Drupal has no idea who or what is requesting the page.
See Also:
Drupal 7 Line by Line Part 1 - Introduction
Drupal 7 Line by Line Part 2 - drupal_bootstrap
Drupal 7 Line by Line Part 3 - DRUPAL_BOOTSTRAP_CONFIGURATION