Commit 6d2ce628 authored by alexpott's avatar alexpott

Revert "Issue #2016629 by larowlan, neclimdul, sun, alexpott, jibran,...

Revert "Issue #2016629 by larowlan, neclimdul, sun, alexpott, jibran, ParisLiakos, donquixote, effulgentsia, msonnabaum: Refactor bootstrap to better utilize the kernel."

This reverts commit cda051c4.
parent b3db2047
...@@ -25,9 +25,8 @@ ErrorDocument 404 /index.php ...@@ -25,9 +25,8 @@ ErrorDocument 404 /index.php
DirectoryIndex index.php index.html index.htm DirectoryIndex index.php index.html index.htm
# Override PHP settings that cannot be changed at runtime. See # Override PHP settings that cannot be changed at runtime. See
# sites/default/default.settings.php and # sites/default/default.settings.php and drupal_environment_initialize() in
# Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be # core/includes/bootstrap.inc for settings that can be changed at runtime.
# changed at runtime.
# PHP 5, Apache 1 and 2. # PHP 5, Apache 1 and 2.
<IfModule mod_php5.c> <IfModule mod_php5.c>
...@@ -120,7 +119,7 @@ DirectoryIndex index.php index.html index.htm ...@@ -120,7 +119,7 @@ DirectoryIndex index.php index.html index.htm
RewriteRule ^ %1/core/%2 [L,QSA,R=301] RewriteRule ^ %1/core/%2 [L,QSA,R=301]
# Pass all requests not referring directly to files in the filesystem to # Pass all requests not referring directly to files in the filesystem to
# index.php. # index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteCond %{REQUEST_URI} !=/favicon.ico
......
...@@ -20,15 +20,13 @@ ...@@ -20,15 +20,13 @@
* @link authorize Authorized operation helper functions @endlink * @link authorize Authorized operation helper functions @endlink
*/ */
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
use Drupal\Core\Page\DefaultHtmlPageRenderer; use Drupal\Core\Page\DefaultHtmlPageRenderer;
// Change the directory to the Drupal root. // Change the directory to the Drupal root.
chdir('..'); chdir('..');
$autoloader = require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
/** /**
* Global flag to identify update.php and authorize.php runs. * Global flag to identify update.php and authorize.php runs.
...@@ -53,9 +51,18 @@ function authorize_access_allowed() { ...@@ -53,9 +51,18 @@ function authorize_access_allowed() {
return Settings::get('allow_authorize_operations', TRUE) && user_access('administer software updates'); return Settings::get('allow_authorize_operations', TRUE) && user_access('administer software updates');
} }
$request = Request::createFromGlobals(); // *** Real work of the script begins here. ***
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel->prepareLegacyRequest($request); require_once __DIR__ . '/includes/bootstrap.inc';
require_once __DIR__ . '/includes/common.inc';
require_once __DIR__ . '/includes/file.inc';
require_once __DIR__ . '/includes/module.inc';
require_once __DIR__ . '/includes/ajax.inc';
// Prepare a minimal bootstrap.
drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE);
$request = \Drupal::request();
\Drupal::service('request_stack')->push($request);
// We have to enable the user and system modules, even to check access and // We have to enable the user and system modules, even to check access and
// display errors via the maintenance theme. // display errors via the maintenance theme.
......
...@@ -201,10 +201,6 @@ services: ...@@ -201,10 +201,6 @@ services:
arguments: ['@access_check.theme', '@request_stack'] arguments: ['@access_check.theme', '@request_stack']
tags: tags:
- { name: service_collector, tag: theme_negotiator, call: addNegotiator } - { name: service_collector, tag: theme_negotiator, call: addNegotiator }
theme.negotiator.request_subscriber:
class: Drupal\Core\EventSubscriber\ThemeNegotiatorRequestSubscriber
tags:
- { name: event_subscriber }
theme.negotiator.default: theme.negotiator.default:
class: Drupal\Core\Theme\DefaultNegotiator class: Drupal\Core\Theme\DefaultNegotiator
arguments: ['@config.factory'] arguments: ['@config.factory']
...@@ -598,6 +594,10 @@ services: ...@@ -598,6 +594,10 @@ services:
tags: tags:
- { name: event_subscriber } - { name: event_subscriber }
arguments: ['@path.alias_manager', '@path_processor_manager'] arguments: ['@path.alias_manager', '@path_processor_manager']
legacy_request_subscriber:
class: Drupal\Core\EventSubscriber\LegacyRequestSubscriber
tags:
- { name: event_subscriber }
finish_response_subscriber: finish_response_subscriber:
class: Drupal\Core\EventSubscriber\FinishResponseSubscriber class: Drupal\Core\EventSubscriber\FinishResponseSubscriber
tags: tags:
......
This diff is collapsed.
...@@ -2603,6 +2603,70 @@ function drupal_valid_token($token, $value = '') { ...@@ -2603,6 +2603,70 @@ function drupal_valid_token($token, $value = '') {
return \Drupal::csrfToken()->validate($token, $value); return \Drupal::csrfToken()->validate($token, $value);
} }
/**
* Loads code for subsystems and modules, and registers stream wrappers.
*/
function _drupal_bootstrap_code() {
require_once __DIR__ . '/../../' . Settings::get('path_inc', 'core/includes/path.inc');
require_once __DIR__ . '/module.inc';
require_once __DIR__ . '/theme.inc';
require_once __DIR__ . '/pager.inc';
require_once __DIR__ . '/../../' . Settings::get('menu_inc', 'core/includes/menu.inc');
require_once __DIR__ . '/tablesort.inc';
require_once __DIR__ . '/file.inc';
require_once __DIR__ . '/unicode.inc';
require_once __DIR__ . '/form.inc';
require_once __DIR__ . '/mail.inc';
require_once __DIR__ . '/ajax.inc';
require_once __DIR__ . '/errors.inc';
require_once __DIR__ . '/schema.inc';
require_once __DIR__ . '/entity.inc';
// Load all enabled modules
\Drupal::moduleHandler()->loadAll();
// Make sure all stream wrappers are registered.
file_get_stream_wrappers();
// Ensure mt_rand() is reseeded to prevent random values from one page load
// being exploited to predict random values in subsequent page loads.
$seed = unpack("L", Crypt::randomBytes(4));
mt_srand($seed[1]);
// Set the allowed protocols once we have the config available.
$allowed_protocols = \Drupal::config('system.filter')->get('protocols');
if (!isset($allowed_protocols)) {
// \Drupal\Component\Utility\UrlHelper::filterBadProtocol() is called by the
// installer and update.php, in which case the configuration may not exist
// (yet). Provide a minimal default set of allowed protocols for these
// cases.
$allowed_protocols = array('http', 'https');
}
UrlHelper::setAllowedProtocols($allowed_protocols);
}
/**
* 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;
if ($called || $skip) {
$called = TRUE;
return;
}
// Let all modules take action before the menu system handles the request.
// We do not want this while running update.php.
if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
drupal_theme_initialize();
}
}
/** /**
* Stores the current page in the cache. * Stores the current page in the cache.
* *
......
...@@ -120,7 +120,7 @@ function _drupal_log_error($error, $fatal = FALSE) { ...@@ -120,7 +120,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
$is_installer = drupal_installation_attempted(); $is_installer = drupal_installation_attempted();
// Initialize a maintenance theme if the bootstrap was not complete. // Initialize a maintenance theme if the bootstrap was not complete.
// Do it early because drupal_set_message() triggers a drupal_theme_initialize(). // Do it early because drupal_set_message() triggers a drupal_theme_initialize().
if ($fatal && drupal_get_bootstrap_phase() < DRUPAL_BOOTSTRAP_CODE) { if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
// The installer initializes a maintenance theme at the earliest possible // The installer initializes a maintenance theme at the earliest possible
// point in time already. Do not unset that. // point in time already. Do not unset that.
if (!$is_installer) { if (!$is_installer) {
...@@ -244,9 +244,9 @@ function _drupal_log_error($error, $fatal = FALSE) { ...@@ -244,9 +244,9 @@ function _drupal_log_error($error, $fatal = FALSE) {
/** /**
* Returns the current error level. * Returns the current error level.
* *
* This function should only be used to get the current error level prior to * This function should only be used to get the current error level pre
* DRUPAL_BOOTSTRAP_KERNEL or before Drupal is installed. In all other situations * DRUPAL_BOOTSTRAP_KERNEL or before Drupal is installed. In all other
* the following code is preferred: * situations the following code is preferred:
* @code * @code
* \Drupal::config('system.logging')->get('error_level'); * \Drupal::config('system.logging')->get('error_level');
* @endcode * @endcode
......
...@@ -272,6 +272,12 @@ function install_begin_request(&$install_state) { ...@@ -272,6 +272,12 @@ function install_begin_request(&$install_state) {
// Allow command line scripts to override server variables used by Drupal. // Allow command line scripts to override server variables used by Drupal.
require_once __DIR__ . '/bootstrap.inc'; require_once __DIR__ . '/bootstrap.inc';
// Initialize conf_path().
// This primes the site path to be used during installation. By not requiring
// settings.php, a bare site folder can be prepared in the /sites directory,
// which will be used for installing Drupal.
conf_path(FALSE);
// If the hash salt leaks, it becomes possible to forge a valid testing user // If the hash salt leaks, it becomes possible to forge a valid testing user
// agent, install a new copy of Drupal, and take over the original site. // agent, install a new copy of Drupal, and take over the original site.
// The user agent header is used to pass a database prefix in the request when // The user agent header is used to pass a database prefix in the request when
...@@ -282,8 +288,7 @@ function install_begin_request(&$install_state) { ...@@ -282,8 +288,7 @@ function install_begin_request(&$install_state) {
exit; exit;
} }
$site_path = DrupalKernel::findSitePath($request, FALSE); drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
Settings::initialize($site_path);
// Ensure that procedural dependencies are loaded as early as possible, // Ensure that procedural dependencies are loaded as early as possible,
// since the error/exception handlers depend on them. // since the error/exception handlers depend on them.
...@@ -351,24 +356,27 @@ function install_begin_request(&$install_state) { ...@@ -351,24 +356,27 @@ function install_begin_request(&$install_state) {
$environment = 'prod'; $environment = 'prod';
} }
$kernel = DrupalKernel::createFromRequest($request, drupal_classloader(), $environment, FALSE); $kernel = new DrupalKernel($environment, drupal_classloader(), FALSE);
$kernel->setSitePath($site_path);
$kernel->boot(); $kernel->boot();
// Enter the request scope and add the Request.
// @todo Remove this after converting all installer screens into controllers.
$container = $kernel->getContainer(); $container = $kernel->getContainer();
$container->enterScope('request');
$container->set('request', $request, 'request');
$container->get('request_stack')->push($request);
// Register the file translation service. // Register the file translation service.
if (isset($GLOBALS['config']['locale.settings']['translation.path'])) { if (isset($GLOBALS['config']['locale.settings']['translation.path'])) {
$directory = $GLOBALS['config']['locale.settings']['translation.path']; $directory = $GLOBALS['config']['locale.settings']['translation.path'];
} }
else { else {
$directory = $site_path . '/files/translations'; $directory = conf_path() . '/files/translations';
} }
$container->set('string_translator.file_translation', new FileTranslation($directory)); $container->set('string_translator.file_translation', new FileTranslation($directory));
$container->get('string_translation') $container->get('string_translation')
->addTranslator($container->get('string_translator.file_translation')); ->addTranslator($container->get('string_translator.file_translation'));
$kernel->prepareLegacyRequest($request);
// Set the default language to the selected language, if any. // Set the default language to the selected language, if any.
if (isset($install_state['parameters']['langcode'])) { if (isset($install_state['parameters']['langcode'])) {
$default_language = new Language(array('id' => $install_state['parameters']['langcode'])); $default_language = new Language(array('id' => $install_state['parameters']['langcode']));
...@@ -1447,6 +1455,7 @@ function install_load_profile(&$install_state) { ...@@ -1447,6 +1455,7 @@ function install_load_profile(&$install_state) {
* An array of information about the current installation state. * An array of information about the current installation state.
*/ */
function install_bootstrap_full() { function install_bootstrap_full() {
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
\Drupal::service('session_manager')->initialize(); \Drupal::service('session_manager')->initialize();
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\OpCodeCache; use Drupal\Component\Utility\OpCodeCache;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
...@@ -632,29 +634,24 @@ function drupal_verify_profile($install_state) { ...@@ -632,29 +634,24 @@ function drupal_verify_profile($install_state) {
* to set the default language. * to set the default language.
*/ */
function drupal_install_system($install_state) { function drupal_install_system($install_state) {
// Remove the service provider of the early installer. // Boot a new kernel into a regular production environment.
$request = \Drupal::hasRequest() ? \Drupal::request() : FALSE;
unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']); unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']);
$kernel = new DrupalKernel('prod', drupal_classloader(), FALSE);
$kernel->boot();
// Reboot into a full production environment to continue the installation. if ($request) {
$kernel = \Drupal::service('kernel'); $kernel->getContainer()->enterScope('request');
$kernel->shutdown(); $kernel->getContainer()->set('request', $request, 'request');
$kernel->prepareLegacyRequest(\Drupal::request()); $kernel->getContainer()->get('request_stack')->push($request);
}
// Install base system configuration. // Install base system configuration.
\Drupal::service('config.installer')->installDefaultConfig('core', 'core'); \Drupal::service('config.installer')->installDefaultConfig('core', 'core');
// Install System module. // Install System module.
$kernel->getContainer()->get('module_handler')->install(array('system'), FALSE); \Drupal::moduleHandler()->install(array('system'), FALSE);
// DrupalKernel::prepareLegacyRequest() above calls into
// DrupalKernel::bootCode(), which primes file_get_stream_wrappers()'s static
// list of custom stream wrappers that are based on the currently enabled
// list of modules (none).
// @todo Custom stream wrappers of a new module have to be registered as soon
// as the module is installed/enabled. Fix either ModuleHandler::install()
// and/or DrupalKernel::updateModules().
// @see https://drupal.org/node/2028109
drupal_static_reset('file_get_stream_wrappers');
// Ensure default language is saved. // Ensure default language is saved.
if (isset($install_state['parameters']['langcode'])) { if (isset($install_state['parameters']['langcode'])) {
......
...@@ -74,7 +74,9 @@ function drupal_match_path($path, $patterns) { ...@@ -74,7 +74,9 @@ function drupal_match_path($path, $patterns) {
* - http://example.com/path/alias (which is a path alias for node/306) returns * - http://example.com/path/alias (which is a path alias for node/306) returns
* "node/306" as opposed to the path alias. * "node/306" as opposed to the path alias.
* *
* @return string * This function is available only after DRUPAL_BOOTSTRAP_FULL.
*
* @return
* The current Drupal URL path. * The current Drupal URL path.
* *
* @see request_path() * @see request_path()
......
...@@ -86,7 +86,7 @@ function drupal_get_complete_schema($rebuild = FALSE) { ...@@ -86,7 +86,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
// If the schema is empty, avoid saving it: some database engines require // If the schema is empty, avoid saving it: some database engines require
// the schema to perform queries, and this could lead to infinite loops. // the schema to perform queries, and this could lead to infinite loops.
if (!empty($schema)) { if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
\Drupal::cache()->set('schema', $schema, Cache::PERMANENT); \Drupal::cache()->set('schema', $schema, Cache::PERMANENT);
} }
} }
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
use Drupal\Core\Theme\ThemeSettings; use Drupal\Core\Theme\ThemeSettings;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
use Symfony\Component\HttpFoundation\Request;
/** /**
* @defgroup content_flags Content markers * @defgroup content_flags Content markers
...@@ -92,11 +91,8 @@ function drupal_theme_access($theme) { ...@@ -92,11 +91,8 @@ function drupal_theme_access($theme) {
/** /**
* Initializes the theme system by loading the theme. * Initializes the theme system by loading the theme.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request for which to initialize the theme.
*/ */
function drupal_theme_initialize(Request $request = NULL) { function drupal_theme_initialize() {
global $theme, $theme_key; global $theme, $theme_key;
// If $theme is already set, assume the others are set, too, and do nothing // If $theme is already set, assume the others are set, too, and do nothing
...@@ -109,9 +105,7 @@ function drupal_theme_initialize(Request $request = NULL) { ...@@ -109,9 +105,7 @@ function drupal_theme_initialize(Request $request = NULL) {
// @todo Let the theme.negotiator listen to the kernel request event. // @todo Let the theme.negotiator listen to the kernel request event.
// Determine the active theme for the theme negotiator service. This includes // Determine the active theme for the theme negotiator service. This includes
// the default theme as well as really specific ones like the ajax base theme. // the default theme as well as really specific ones like the ajax base theme.
if (!$request) { $request = \Drupal::request();
$request = \Drupal::request();
}
$theme = \Drupal::service('theme.negotiator')->determineActiveTheme($request); $theme = \Drupal::service('theme.negotiator')->determineActiveTheme($request);
// If no theme could be negotiated, or if the negotiated theme is not within // If no theme could be negotiated, or if the negotiated theme is not within
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
use Drupal\Component\Utility\Variable; use Drupal\Component\Utility\Variable;
use Drupal\Core\PhpStorage\PhpStorageFactory; use Drupal\Core\PhpStorage\PhpStorageFactory;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Composer\Autoload\ClassLoader;
/** /**
* Drupal-friendly var_export(). * Drupal-friendly var_export().
...@@ -35,39 +32,34 @@ function drupal_var_export($var, $prefix = '') { ...@@ -35,39 +32,34 @@ function drupal_var_export($var, $prefix = '') {
* *
* Requires DRUPAL_BOOTSTRAP_CONFIGURATION. * Requires DRUPAL_BOOTSTRAP_CONFIGURATION.
* *
* @param \Composer\Autoload\ClassLoader $classloader
* The classloader.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @see rebuild.php * @see rebuild.php
*/ */
function drupal_rebuild(ClassLoader $classloader, Request $request) { function drupal_rebuild() {
// Remove Drupal's error and exception handlers; they rely on a working // Remove Drupal's error and exception handlers; they rely on a working
// service container and other subsystems and will only cause a fatal error // service container and other subsystems and will only cause a fatal error
// that hides the actual error. // that hides the actual error.
restore_error_handler(); restore_error_handler();
restore_exception_handler(); restore_exception_handler();
// Force kernel to rebuild container. // drupal_bootstrap(DRUPAL_BOOTSTRAP_KERNEL) will build a new kernel. This
// comes before DRUPAL_BOOTSTRAP_PAGE_CACHE.
PhpStorageFactory::get('service_container')->deleteAll(); PhpStorageFactory::get('service_container')->deleteAll();
PhpStorageFactory::get('twig')->deleteAll(); PhpStorageFactory::get('twig')->deleteAll();
// Bootstrap up to where caches exist and clear them. // Disable the page cache.
$kernel = new DrupalKernel('prod', $classloader); drupal_page_is_cacheable(FALSE);
$kernel->prepareLegacyRequest($request);
// Bootstrap up to where caches exist and clear them.
drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE);
foreach (Cache::getBins() as $bin) { foreach (Cache::getBins() as $bin) {
$bin->deleteAll(); $bin->deleteAll();
} }
// Disable the page cache. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_page_is_cacheable(FALSE);
drupal_flush_all_caches(); drupal_flush_all_caches();
// Restore Drupal's error and exception handlers. // Restore Drupal's error and exception handlers.
// @see \Drupal\Core\DrupalKernel::boot() // @see _drupal_bootstrap_configuration()
set_error_handler('_drupal_error_handler'); set_error_handler('_drupal_error_handler');
set_exception_handler('_drupal_exception_handler'); set_exception_handler('_drupal_exception_handler');
} }
This diff is collapsed.
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\Core; namespace Drupal\Core;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* The interface for DrupalKernel, the core of Drupal. * The interface for DrupalKernel, the core of Drupal.
...@@ -20,8 +19,6 @@ interface DrupalKernelInterface extends HttpKernelInterface { ...@@ -20,8 +19,6 @@ interface DrupalKernelInterface extends HttpKernelInterface {
/** /**
* Boots the current kernel. * Boots the current kernel.
*
* @return $this
*/ */
public function boot(); public function boot();
...@@ -56,22 +53,6 @@ public function getServiceProviders($origin); ...@@ -56,22 +53,6 @@ public function getServiceProviders($origin);
*/ */
public function getContainer(); public function getContainer();
/**
* Set the current site path.
*
* @param $path
* The current site path.
*/
public function setSitePath($path);
/**
* Get the site path.
*
* @return string
* The current site path.
*/
public function getSitePath();
/** /**
* Updates the kernel's list of modules to the new list. * Updates the kernel's list of modules to the new list.
* *
...@@ -84,28 +65,4 @@ public function getSitePath(); ...@@ -84,28 +65,4 @@ public function getSitePath();
* List of module filenames, keyed by module name. * List of module filenames, keyed by module name.
*/ */
public function updateModules(array $module_list, array $module_filenames = array()); public function updateModules(array $module_list, array $module_filenames = array());
/**
* Attempts to serve a page from the cache.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @return $this
*/
public function handlePageCache(Request $request);
/**
* Prepare the kernel for handling a request without handling the request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @return $this
*
* @deprecated 8.x
* Only used by legacy front-controller scripts.
*/
public function prepareLegacyRequest(Request $request);
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains \Drupal\Core\EventSubscriber\ThemeNegotiatorRequestSubscriber. * Definition of Drupal\Core\EventSubscriber\LegacyRequestSubscriber.
*/ */
namespace Drupal\Core\EventSubscriber; namespace Drupal\Core\EventSubscriber;
...@@ -13,9 +13,28 @@ ...@@ -13,9 +13,28 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/** /**
* Initializes the theme for the current request. * KernelEvents::REQUEST event subscriber to initialize theme and modules.
*
* @todo Remove this subscriber when all of the code in it has been refactored.
*/ */
class ThemeNegotiatorRequestSubscriber implements EventSubscriberInterface { class LegacyRequestSubscriber implements EventSubscriberInterface {
/**
* Initializes the rest of the legacy Drupal subsystems.
*
* @param Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The Event to process.
*/
public function onKernelRequestLegacy(GetResponseEvent $event) {
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
// Tell Drupal it is now fully bootstrapped (for the benefit of code that
// calls drupal_get_bootstrap_phase()), but without having
// _drupal_bootstrap_full() do anything, since we've already done the
// equivalent above and in earlier listeners.
_drupal_bootstrap_full(TRUE);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
}
}
/** /**
* Initializes the theme system after the routing system. * Initializes the theme system after the routing system.
...@@ -23,13 +42,9 @@ class ThemeNegotiatorRequestSubscriber implements EventSubscriberInterface { ...@@ -23,13 +42,9 @@ class ThemeNegotiatorRequestSubscriber implements EventSubscriberInterface {
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The Event to process. * The Event to process.
*/ */
public function onKernelRequestThemeNegotiator(GetResponseEvent $event) { public function onKernelRequestLegacyAfterRouting(GetResponseEvent $event) {
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') { drupal_theme_initialize();
// @todo Refactor drupal_theme_initialize() into a request subscriber.
// @see https://drupal.org/node/2228093
drupal_theme_initialize($event->getRequest());
}
} }
} }
...@@ -39,9 +54,11 @@ public function onKernelRequestThemeNegotiator(GetResponseEvent $event) { ...@@ -39,9 +54,11 @@ public function onKernelRequestThemeNegotiator(GetResponseEvent $event) {
* @return array * @return array
* An array of event listener definitions. * An array of event listener definitions.
*/ */
public static function getSubscribedEvents() { static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = array('onKernelRequestThemeNegotiator', 29); $events[KernelEvents::REQUEST][] = array('onKernelRequestLegacy', 90);
// Initialize the theme system after the routing system.
$events[KernelEvents::REQUEST][] = array('onKernelRequestLegacyAfterRouting', 30);
return $events; return $events;
} }
} }
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
namespace Drupal\Core\Site; namespace Drupal\Core\Site;
use Drupal\Core\Database\Database;
/** /**
* Read only settings that are initialized with the class. * Read only settings that are initialized with the class.
* *
...@@ -82,31 +80,6 @@ public static function getAll() { ...@@ -82,31 +80,6 @@ public static function getAll() {
return self::$instance->storage; return self::$instance->storage;
}