refs #1536844 Clean up bootstrap shivs.

8.0.x
effulgentsia 2012-05-23 23:52:03 -05:00 committed by Larry Garfield
parent 14416d109e
commit 35ef2c97ea
5 changed files with 31 additions and 15 deletions

View File

@ -138,8 +138,7 @@ const DRUPAL_BOOTSTRAP_SESSION = 4;
const DRUPAL_BOOTSTRAP_PAGE_HEADER = 5;
/**
* Seventh bootstrap phase: load code for subsystems and modules; validate and
* fix input data.
* Seventh bootstrap phase: load code for subsystems and modules.
*/
const DRUPAL_BOOTSTRAP_CODE = 6;

View File

@ -5160,13 +5160,10 @@ function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
return (($skip_anonymous && $user->uid == 0) || ($token == drupal_get_token($value)));
}
/**
* Loads code for subsystems and modules, and registers stream wrappers.
*/
function _drupal_bootstrap_code() {
static $called = FALSE;
if ($called) {
return;
}
$called = TRUE;
require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
require_once DRUPAL_ROOT . '/core/includes/theme.inc';
require_once DRUPAL_ROOT . '/core/includes/pager.inc';
@ -5183,19 +5180,22 @@ function _drupal_bootstrap_code() {
require_once DRUPAL_ROOT . '/core/includes/errors.inc';
require_once DRUPAL_ROOT . '/core/includes/schema.inc';
// Detect string handling method
// @todo Move this to earlier in bootstrap: http://drupal.org/node/1569456.
unicode_check();
// Undo magic quotes
// @todo Remove this: http://drupal.org/node/1569456.
fix_gpc_magic();
// Load all enabled modules
// Load all enabled modules.
module_load_all();
// Make sure all stream wrappers are registered.
file_get_stream_wrappers();
// Now that stream wrappers are registered, log fatal errors from a simpletest
// child site to a test specific file directory.
$test_info = &$GLOBALS['drupal_test_info'];
if (!empty($test_info['in_child_site'])) {
// Running inside the simpletest child site, log fatal errors to test
// specific file directory.
ini_set('log_errors', 1);
ini_set('error_log', 'public://error.log');
}
@ -5205,6 +5205,9 @@ function _drupal_bootstrap_code() {
* Temporary BC function for scripts not using DrupalKernel.
*
* DrupalKernel skips this and replicates it via event listeners.
*
* @see Drupal\Core\EventSubscriber\PathSubscriber;
* @see Drupal\Core\EventSubscriber\LegacyRequestSubscriber;
*/
function _drupal_bootstrap_full($skip = FALSE) {
static $called = FALSE;

View File

@ -28,6 +28,13 @@ class LegacyRequestSubscriber implements EventSubscriberInterface {
*/
public function onKernelRequestLegacy(GetResponseEvent $event) {
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
// Prior to invoking hook_init(), initialize the theme (potentially a
// custom one for this page), so that:
// - Modules with hook_init() implementations that call theme() or
// theme_get_registry() don't initialize the incorrect theme.
// - The theme can have hook_*_alter() implementations affect page
// building (e.g., hook_form_alter(), hook_node_view_alter(),
// hook_page_alter()), ahead of when rendering starts.
menu_set_custom_theme();
drupal_theme_initialize();
module_invoke_all('init');

View File

@ -439,9 +439,11 @@ if (is_null($op) && update_access_allowed()) {
install_goto('core/update.php?op=info');
}
// Bootstrap, fix requirements, and set the maintenance theme.
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Allow update_fix_d8_requirements() to run before code that can break on a
// Drupal 7 database.
drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
update_fix_d8_requirements();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_maintenance_theme();
// Turn error reporting back on. From now on, only fatal errors (which are

View File

@ -32,6 +32,11 @@ $request = Request::createFromGlobals();
// container at some point.
request($request);
// Bootstrap all of Drupal's subsystems, but do not initialize anything that
// depends on the fully resolved Drupal path, because path resolution happens
// during the REQUEST event of the kernel.
// @see Drupal\Core\EventSubscriber\PathSubscriber;
// @see Drupal\Core\EventSubscriber\LegacyRequestSubscriber;
drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
$dispatcher = new EventDispatcher();