Commit 7d3be895 authored by catch's avatar catch

Issue #2392787 by beejeebus, dawehner, alexpott: Move include statements from...

Issue #2392787 by beejeebus, dawehner, alexpott: Move include statements from DrupalKernel::boot() into DrupalKernel::preHandle()
parent 5a581ddc
...@@ -428,7 +428,7 @@ services: ...@@ -428,7 +428,7 @@ services:
arguments: ['@kernel'] arguments: ['@kernel']
controller_resolver: controller_resolver:
class: Drupal\Core\Controller\ControllerResolver class: Drupal\Core\Controller\ControllerResolver
arguments: ['@class_resolver', '@logger.channel.default'] arguments: ['@class_resolver']
class_resolver: class_resolver:
class: Drupal\Core\DependencyInjection\ClassResolver class: Drupal\Core\DependencyInjection\ClassResolver
calls: calls:
......
...@@ -293,6 +293,23 @@ function drupal_get_filename($type, $name, $filename = NULL) { ...@@ -293,6 +293,23 @@ function drupal_get_filename($type, $name, $filename = NULL) {
} }
} }
/**
* Returns the path to a system item (module, theme, etc.).
*
* @param $type
* The type of the item; one of 'core', 'profile', 'module', 'theme', or
* 'theme_engine'.
* @param $name
* The name of the item for which the path is requested. Ignored for
* $type 'core'.
*
* @return
* The path to the requested item or an empty string if the item is not found.
*/
function drupal_get_path($type, $name) {
return dirname(drupal_get_filename($type, $name));
}
/** /**
* Gets the page cache cid for this request. * Gets the page cache cid for this request.
* *
...@@ -1066,6 +1083,39 @@ function drupal_installation_attempted() { ...@@ -1066,6 +1083,39 @@ function drupal_installation_attempted() {
return isset($GLOBALS['install_state']) && empty($GLOBALS['install_state']['installation_finished']); return isset($GLOBALS['install_state']) && empty($GLOBALS['install_state']['installation_finished']);
} }
/**
* Gets the name of the currently active installation profile.
*
* When this function is called during Drupal's initial installation process,
* the name of the profile that's about to be installed is stored in the global
* installation state. At all other times, the "install_profile" setting will be
* available in settings.php.
*
* @return string|null $profile
* The name of the installation profile or NULL if no installation profile is
* currently active. This is the case for example during the first steps of
* the installer or during unit tests.
*/
function drupal_get_profile() {
global $install_state;
if (drupal_installation_attempted()) {
// If the profile has been selected return it.
if (isset($install_state['parameters']['profile'])) {
$profile = $install_state['parameters']['profile'];
}
else {
$profile = NULL;
}
}
else {
// Fall back to NULL, if there is no 'install_profile' setting.
$profile = Settings::get('install_profile');
}
return $profile;
}
/** /**
* Returns a list of languages set up on the site. * Returns a list of languages set up on the site.
* *
......
...@@ -144,39 +144,6 @@ ...@@ -144,39 +144,6 @@
*/ */
const LOCALE_PLURAL_DELIMITER = "\03"; const LOCALE_PLURAL_DELIMITER = "\03";
/**
* Gets the name of the currently active installation profile.
*
* When this function is called during Drupal's initial installation process,
* the name of the profile that's about to be installed is stored in the global
* installation state. At all other times, the "install_profile" setting will be
* available in settings.php.
*
* @return string|null $profile
* The name of the installation profile or NULL if no installation profile is
* currently active. This is the case for example during the first steps of
* the installer or during unit tests.
*/
function drupal_get_profile() {
global $install_state;
if (drupal_installation_attempted()) {
// If the profile has been selected return it.
if (isset($install_state['parameters']['profile'])) {
$profile = $install_state['parameters']['profile'];
}
else {
$profile = NULL;
}
}
else {
// Fall back to NULL, if there is no 'install_profile' setting.
$profile = Settings::get('install_profile');
}
return $profile;
}
/** /**
* Adds output to the HEAD tag of the HTML page. * Adds output to the HEAD tag of the HTML page.
* *
...@@ -798,23 +765,6 @@ function drupal_set_time_limit($time_limit) { ...@@ -798,23 +765,6 @@ function drupal_set_time_limit($time_limit) {
} }
} }
/**
* Returns the path to a system item (module, theme, etc.).
*
* @param $type
* The type of the item; one of 'core', 'profile', 'module', 'theme', or
* 'theme_engine'.
* @param $name
* The name of the item for which the path is requested. Ignored for
* $type 'core'.
*
* @return
* The path to the requested item or an empty string if the item is not found.
*/
function drupal_get_path($type, $name) {
return dirname(drupal_get_filename($type, $name));
}
/** /**
* Returns the base URL path (i.e., directory) of the Drupal installation. * Returns the base URL path (i.e., directory) of the Drupal installation.
* *
......
...@@ -30,13 +30,6 @@ ...@@ -30,13 +30,6 @@
*/ */
class ControllerResolver extends BaseControllerResolver implements ControllerResolverInterface { class ControllerResolver extends BaseControllerResolver implements ControllerResolverInterface {
/**
* The PSR-3 logger. (optional)
*
* @var \Psr\Log\LoggerInterface;
*/
protected $logger;
/** /**
* The class resolver. * The class resolver.
* *
...@@ -49,13 +42,9 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes ...@@ -49,13 +42,9 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes
* *
* @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver
* The class resolver. * The class resolver.
* @param \Psr\Log\LoggerInterface $logger
* (optional) A LoggerInterface instance.
*/ */
public function __construct(ClassResolverInterface $class_resolver, LoggerInterface $logger = NULL) { public function __construct(ClassResolverInterface $class_resolver) {
$this->classResolver = $class_resolver; $this->classResolver = $class_resolver;
parent::__construct($logger);
} }
/** /**
...@@ -90,10 +79,6 @@ public function getControllerFromDefinition($controller, $path = '') { ...@@ -90,10 +79,6 @@ public function getControllerFromDefinition($controller, $path = '') {
*/ */
public function getController(Request $request) { public function getController(Request $request) {
if (!$controller = $request->attributes->get('_controller')) { if (!$controller = $request->attributes->get('_controller')) {
if ($this->logger !== NULL) {
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
}
return FALSE; return FALSE;
} }
return $this->getControllerFromDefinition($controller, $request->getPathInfo()); return $this->getControllerFromDefinition($controller, $request->getPathInfo());
......
...@@ -377,22 +377,6 @@ public function boot() { ...@@ -377,22 +377,6 @@ public function boot() {
// Start a page timer: // Start a page timer:
Timer::start('page'); Timer::start('page');
// Load legacy and other functional code.
require_once $this->root . '/core/includes/common.inc';
require_once $this->root . '/core/includes/database.inc';
require_once $this->root . '/core/includes/path.inc';
require_once $this->root . '/core/includes/module.inc';
require_once $this->root . '/core/includes/theme.inc';
require_once $this->root . '/core/includes/pager.inc';
require_once $this->root . '/core/includes/menu.inc';
require_once $this->root . '/core/includes/tablesort.inc';
require_once $this->root . '/core/includes/file.inc';
require_once $this->root . '/core/includes/unicode.inc';
require_once $this->root . '/core/includes/form.inc';
require_once $this->root . '/core/includes/errors.inc';
require_once $this->root . '/core/includes/schema.inc';
require_once $this->root . '/core/includes/entity.inc';
// Ensure that findSitePath is set. // Ensure that findSitePath is set.
if (!$this->sitePath) { if (!$this->sitePath) {
throw new \Exception('Kernel does not have site path set before calling boot()'); throw new \Exception('Kernel does not have site path set before calling boot()');
...@@ -431,10 +415,33 @@ public function getContainer() { ...@@ -431,10 +415,33 @@ public function getContainer() {
return $this->container; return $this->container;
} }
/**
* {@inheritdoc}
*/
public function loadLegacyIncludes() {
require_once $this->root . '/core/includes/common.inc';
require_once $this->root . '/core/includes/database.inc';
require_once $this->root . '/core/includes/path.inc';
require_once $this->root . '/core/includes/module.inc';
require_once $this->root . '/core/includes/theme.inc';
require_once $this->root . '/core/includes/pager.inc';
require_once $this->root . '/core/includes/menu.inc';
require_once $this->root . '/core/includes/tablesort.inc';
require_once $this->root . '/core/includes/file.inc';
require_once $this->root . '/core/includes/unicode.inc';
require_once $this->root . '/core/includes/form.inc';
require_once $this->root . '/core/includes/errors.inc';
require_once $this->root . '/core/includes/schema.inc';
require_once $this->root . '/core/includes/entity.inc';
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function preHandle(Request $request) { public function preHandle(Request $request) {
$this->loadLegacyIncludes();
// Load all enabled modules. // Load all enabled modules.
$this->container->get('module_handler')->loadAll(); $this->container->get('module_handler')->loadAll();
......
...@@ -124,4 +124,9 @@ public function prepareLegacyRequest(Request $request); ...@@ -124,4 +124,9 @@ public function prepareLegacyRequest(Request $request);
*/ */
public function preHandle(Request $request); public function preHandle(Request $request);
/**
* Helper method that loads legacy Drupal include files.
*/
public function loadLegacyIncludes();
} }
...@@ -79,6 +79,7 @@ public function boot() { ...@@ -79,6 +79,7 @@ public function boot() {
$this->getContainer()->get('stream_wrapper_manager')->register(); $this->getContainer()->get('stream_wrapper_manager')->register();
// Create the build/artifacts directory if necessary. // Create the build/artifacts directory if necessary.
include_once DRUPAL_ROOT . '/core/includes/file.inc';
if (!is_dir('public://simpletest')) { if (!is_dir('public://simpletest')) {
mkdir('public://simpletest', 0777, TRUE); mkdir('public://simpletest', 0777, TRUE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment