summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-10-24 11:30:39 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-10-24 11:30:39 +0000
commit7e963c13ff54ebef2ebc90cdecb18c5f1480f339 (patch)
tree68881e9168938b7e1337ce4ae7170ed1ca2d8002 /includes
parent8903cda5ca13f96aad3d9a074937644347620054 (diff)
downloadbrdo-7e963c13ff54ebef2ebc90cdecb18c5f1480f339.tar.gz
brdo-7e963c13ff54ebef2ebc90cdecb18c5f1480f339.tar.bz2
#182675 by chx: fix caching bootstrap, so hook_boot() and the timer is called when required, integrating the cache init function right into the bootstrap
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc69
-rw-r--r--includes/common.inc2
2 files changed, 33 insertions, 38 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 433641755..11f69c539 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -885,12 +885,23 @@ function _drupal_bootstrap($phase) {
case DRUPAL_BOOTSTRAP_CONFIGURATION:
drupal_unset_globals();
+ // Start a page timer:
+ timer_start('page');
// Initialize the configuration
conf_init();
break;
case DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE:
- _drupal_cache_init($phase);
+ // Allow specifying special cache handlers in settings.php, like
+ // using memcached or files for storing cache information.
+ require_once variable_get('cache_inc', './includes/cache.inc');
+ // If the page_cache_fastpath is set to TRUE in settings.php and
+ // page_cache_fastpath (implemented in the special implementation of
+ // cache.inc) printed the page and indicated this with a returned TRUE
+ // then we are done.
+ if (variable_get('page_cache_fastpath', FALSE) && page_cache_fastpath()) {
+ exit;
+ }
break;
case DRUPAL_BOOTSTRAP_DATABASE:
@@ -917,13 +928,26 @@ function _drupal_bootstrap($phase) {
case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE:
// Initialize configuration variables, using values from settings.php if available.
$conf = variable_init(isset($conf) ? $conf : array());
-
- _drupal_cache_init($phase);
-
- // Start a page timer:
- timer_start('page');
-
- bootstrap_invoke_all('boot');
+ // Load module handling.
+ require_once './includes/module.inc';
+ $cache_mode = variable_get('cache', CACHE_DISABLED);
+ // Get the page from the cache.
+ $cache = $cache_mode == CACHE_DISABLED ? '' : page_get_cache();
+ // If the skipping of the bootstrap hooks is not enforced, call hook_boot.
+ if ($cache_mode != CACHE_AGGRESSIVE) {
+ bootstrap_invoke_all('boot');
+ }
+ // If there is a cached page, display it.
+ if ($cache) {
+ drupal_page_cache_header($cache);
+ // If the skipping of the bootstrap hooks is not enforced, call hook_exit.
+ if ($cache_mode != CACHE_AGGRESSIVE) {
+ bootstrap_invoke_all('exit');
+ }
+ // We are done.
+ exit;
+ }
+ // Prepare for non-cached page workflow.
drupal_page_header();
break;
@@ -945,35 +969,6 @@ function _drupal_bootstrap($phase) {
}
/**
- * Initialize the caching strategy, which loads at different stages within
- * Drupal's bootstrap process.
- */
-function _drupal_cache_init($phase) {
- require_once variable_get('cache_inc', './includes/cache.inc');
-
- if ($phase == DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE && variable_get('page_cache_fastpath', 0)) {
- if (page_cache_fastpath()) {
- exit();
- }
- }
- elseif ($phase == DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE) {
- if ($cache = page_get_cache()) {
- if (variable_get('cache', CACHE_DISABLED) == CACHE_AGGRESSIVE) {
- drupal_page_cache_header($cache);
- exit();
- }
- elseif (variable_get('cache', CACHE_DISABLED) == CACHE_NORMAL) {
- require_once './includes/module.inc';
- drupal_page_cache_header($cache);
- bootstrap_invoke_all('exit');
- exit();
- }
- }
- require_once './includes/module.inc';
- }
-}
-
-/**
* Enables use of the theme system without requiring database access. Since
* there is not database access no theme will be enabled and the default
* themeable functions will be called. Some themeable functions can not be used
diff --git a/includes/common.inc b/includes/common.inc
index 77aa900b9..bb7a020cd 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1405,7 +1405,7 @@ function l($text, $path, $options = array()) {
* react to the closing of the page by calling hook_exit().
*/
function drupal_page_footer() {
- if (variable_get('cache', 0)) {
+ if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED) {
page_set_cache();
}