diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index b358269..d0326a3 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -5,6 +5,8 @@ use Symfony\Component\ClassLoader\UniversalClassLoader; use Symfony\Component\ClassLoader\ApcUniversalClassLoader; use Drupal\Core\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpFoundation\Request; +use Drupal\Core\Config\DrupalConfig; +use Drupal\Core\Config\NullStorage; /** * @file @@ -671,8 +673,12 @@ function drupal_settings_initialize() { // Make conf_path() available as local variable in settings.php. $conf_path = conf_path(); - if (file_exists(DRUPAL_ROOT . '/' . $conf_path . '/settings.php')) { - include_once DRUPAL_ROOT . '/' . $conf_path . '/settings.php'; + if (file_exists($file = DRUPAL_ROOT . '/' . $conf_path . '/settings.php')) { + include_once $file; + } + // If running as a SimpleTest child site, load additional per-test settings. + if (($test_prefix = drupal_valid_test_ua()) && file_exists($file = DRUPAL_ROOT . '/' . $conf_path . '/files/simpletest/' . substr($test_prefix, 10) . '/settings.php')) { + include_once $file; } $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'; @@ -1270,7 +1276,7 @@ function drupal_page_header() { * response is sent. */ function drupal_serve_page_from_cache(stdClass $cache) { - $config = config('system.performance'); + $config = variable_get('page_cache_without_database') ? new DrupalConfig(new NullStorage('system.performance')) : config('system.performance'); // Negotiate whether to use compression. $page_compression = $config->get('page_compression') && extension_loaded('zlib'); @@ -2304,14 +2310,14 @@ function _drupal_bootstrap_page_cache() { drupal_set_title($cache->data['title'], PASS_THROUGH); date_default_timezone_set(drupal_get_user_timezone()); // If the skipping of the bootstrap hooks is not enforced, call - // hook_boot. - if (variable_get('page_cache_invoke_hooks', TRUE)) { + // hook_boot. Hooks cannot be invoked without database access. + if (!variable_get('page_cache_without_database') && variable_get('page_cache_invoke_hooks', TRUE)) { bootstrap_invoke_all('boot'); } drupal_serve_page_from_cache($cache); // If the skipping of the bootstrap hooks is not enforced, call - // hook_exit. - if (variable_get('page_cache_invoke_hooks', TRUE)) { + // hook_exit. Hooks cannot be invoked without database access. + if (!variable_get('page_cache_without_database') && variable_get('page_cache_invoke_hooks', TRUE)) { bootstrap_invoke_all('exit'); } // We are done. diff --git a/core/lib/Drupal/Core/Config/NullStorage.php b/core/lib/Drupal/Core/Config/NullStorage.php new file mode 100644 index 0000000..9e0af28 --- /dev/null +++ b/core/lib/Drupal/Core/Config/NullStorage.php @@ -0,0 +1,50 @@ +public_files_directory . '/settings.php', $settings); + $this->drupalGet(''); + $this->assertText('Page returned by Drupal\bootstrap_test\Cache\TestBackend'); + } + + /** * Test page compression. * * The test should pass even if zlib.output_compression is enabled in php.ini, diff --git a/core/modules/system/tests/modules/bootstrap_test/lib/Drupal/bootstrap_test/Cache/TestBackend.php b/core/modules/system/tests/modules/bootstrap_test/lib/Drupal/bootstrap_test/Cache/TestBackend.php new file mode 100644 index 0000000..8812398 --- /dev/null +++ b/core/modules/system/tests/modules/bootstrap_test/lib/Drupal/bootstrap_test/Cache/TestBackend.php @@ -0,0 +1,31 @@ + time(), + 'data' => array( + 'path' => 'node', + 'title' => 'Foo', + 'headers' => array(), + 'body' => 'Page returned by Drupal\bootstrap_test\Cache\TestBackend', + ), + ); + } + +}