diff --git a/core/core.services.yml b/core/core.services.yml index 8a5a126e5440a3ffcde8260141a6753c55efe42e..d4f021d1395bc296939c359fe0ab42777b78fac8 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -428,7 +428,7 @@ services: arguments: ['@kernel'] controller_resolver: class: Drupal\Core\Controller\ControllerResolver - arguments: ['@class_resolver', '@logger.channel.default'] + arguments: ['@class_resolver'] class_resolver: class: Drupal\Core\DependencyInjection\ClassResolver calls: diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index ae3f55ac27c151bd6d69effdf355d679c5978d8f..ff20f28fba076425b37ed23a57bad7fc7b779aac 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -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. * @@ -1066,6 +1083,39 @@ function drupal_installation_attempted() { 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. * diff --git a/core/includes/common.inc b/core/includes/common.inc index 6d1b013ed18e78dcb354567d2e2d2cc4644c59ed..08f25f285a5323bc11defa5ef4463aef1e4966c4 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -144,39 +144,6 @@ */ 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. * @@ -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. * diff --git a/core/lib/Drupal/Core/Controller/ControllerResolver.php b/core/lib/Drupal/Core/Controller/ControllerResolver.php index febffd906ed3b6b7dab8ec621bf21686b03d1b61..eb78f6c4db09aba63c151135d6a346d5fe45cb24 100644 --- a/core/lib/Drupal/Core/Controller/ControllerResolver.php +++ b/core/lib/Drupal/Core/Controller/ControllerResolver.php @@ -30,13 +30,6 @@ */ class ControllerResolver extends BaseControllerResolver implements ControllerResolverInterface { - /** - * The PSR-3 logger. (optional) - * - * @var \Psr\Log\LoggerInterface; - */ - protected $logger; - /** * The class resolver. * @@ -49,13 +42,9 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes * * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $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; - - parent::__construct($logger); } /** @@ -90,10 +79,6 @@ public function getControllerFromDefinition($controller, $path = '') { */ public function getController(Request $request) { 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 $this->getControllerFromDefinition($controller, $request->getPathInfo()); diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index d5e6059345b71206692d421fa6e884331bef978f..ac9dbeef7f30d5b1a74e2cb857ad30845bcb7884 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -377,22 +377,6 @@ public function boot() { // Start a page timer: 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. if (!$this->sitePath) { throw new \Exception('Kernel does not have site path set before calling boot()'); @@ -431,10 +415,33 @@ public function getContainer() { 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} */ public function preHandle(Request $request) { + + $this->loadLegacyIncludes(); + // Load all enabled modules. $this->container->get('module_handler')->loadAll(); diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php index e7c468fb0506a3906d7ae745b7a86c00088cf77e..0ba61dee2dfcfa9694ac8952d056befd3f569e6e 100644 --- a/core/lib/Drupal/Core/DrupalKernelInterface.php +++ b/core/lib/Drupal/Core/DrupalKernelInterface.php @@ -124,4 +124,9 @@ public function prepareLegacyRequest(Request $request); */ public function preHandle(Request $request); + /** + * Helper method that loads legacy Drupal include files. + */ + public function loadLegacyIncludes(); + } diff --git a/core/lib/Drupal/Core/Test/TestRunnerKernel.php b/core/lib/Drupal/Core/Test/TestRunnerKernel.php index 0b2f790b8e3b6db65798f1f2bd7d681e4bd9a861..a6dc573c0795ffe632971e25b88c29f955c9be7d 100644 --- a/core/lib/Drupal/Core/Test/TestRunnerKernel.php +++ b/core/lib/Drupal/Core/Test/TestRunnerKernel.php @@ -79,6 +79,7 @@ public function boot() { $this->getContainer()->get('stream_wrapper_manager')->register(); // Create the build/artifacts directory if necessary. + include_once DRUPAL_ROOT . '/core/includes/file.inc'; if (!is_dir('public://simpletest')) { mkdir('public://simpletest', 0777, TRUE); }