#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
parent
8903cda5ca
commit
7e963c13ff
|
@ -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;
|
||||
|
||||
|
@ -944,35 +968,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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue