diff -u b/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php --- b/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -182,15 +182,17 @@ * Create a DrupalKernel object from a request. * * @param \Symfony\Component\HttpFoundation\Request $request - * @param $class_loader - * The class loader to use. Usually an instance of - * \Composer\Autoload\Classloader or + * The request. + * @param \Composer\Autoload\ClassLoader $class_loader + * The class loader. Normally Composer's ClassLoader, as included by the + * front controller, but may also be decorated; e.g., * \Symfony\Component\ClassLoader\ApcClassLoader. * @param string $environment * String indicating the environment, e.g. 'prod' or 'dev'. * @param bool $allow_dumping * (optional) FALSE to stop the container from being written to or read * from disk. Defaults to TRUE. + * * @return static */ public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = TRUE) { @@ -221,15 +223,8 @@ * * @param \Symfony\Component\HttpFoundation\Request $request * The request that will be used to determine the site path. - * - * @return $this */ - public function initializeSettings(Request $request) { - // This should not be called multiple times. - if (isset($this->sitePath)) { - throw new \BadMethodCallException('Do not initialize settings multiple times.'); - } - + protected function initializeSettings(Request $request) { $site_path = static::findSitePath($request); $this->setSitePath($site_path); Settings::initialize($site_path, $this->classLoader); @@ -241,8 +236,8 @@ * @param string $environment * String indicating the environment, e.g. 'prod' or 'dev'. * @param $class_loader - * The class loader to use. Usually an instance of - * \Composer\Autoload\Classloader or + * The class loader. Normally \Composer\Autoload\ClassLoader, as included by + * the front controller, but may also be decorated; e.g., * \Symfony\Component\ClassLoader\ApcClassLoader. * @param bool $allow_dumping * (optional) FALSE to stop the container from being written to or read diff -u b/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php --- b/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -88,9 +88,9 @@ * @param string $site_path * The current site path. * @param \Composer\Autoload\ClassLoader $class_loader - * The class loader that is used for this request. This is passed by - * reference and exposed to the settings.php file to allow for it to be - * wrapped with Symfony's ApcClassLoader, for example. + * The class loader that is used for this request. Passed by reference and + * exposed to the local scope of settings.php, so as to allow it to be + * decorated with Symfony's ApcClassLoader, for example. * * @see default.settings.php */ diff -u b/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php --- b/core/modules/simpletest/src/InstallerTestBase.php +++ b/core/modules/simpletest/src/InstallerTestBase.php @@ -138,7 +138,7 @@ // Import new settings.php written by the installer. $request = Request::createFromGlobals(); - $class_loader = require __DIR__ . '/../../../vendor/autoload.php'; + $class_loader = require DRUPAL_ROOT . '/core/vendor/autoload.php'; Settings::initialize(DrupalKernel::findSitePath($request), $class_loader); foreach ($GLOBALS['config_directories'] as $type => $path) { $this->configDirectories[$type] = $path; diff -u b/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php --- b/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -154,7 +154,7 @@ // Back up settings from TestBase::prepareEnvironment(). $settings = Settings::getAll(); // Bootstrap a new kernel. Don't use createFromRequest so we don't mess with settings. - $class_loader = require __DIR__ . '/../../../vendor/autoload.php'; + $class_loader = require DRUPAL_ROOT . '/core/vendor/autoload.php'; $this->kernel = new DrupalKernel('testing', $class_loader, FALSE); $request = Request::create('/'); $this->kernel->setSitePath(DrupalKernel::findSitePath($request)); diff -u b/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php --- b/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -853,7 +853,7 @@ // Since Drupal is bootstrapped already, install_begin_request() will not // bootstrap into DRUPAL_BOOTSTRAP_CONFIGURATION (again). Hence, we have to // reload the newly written custom settings.php manually. - $class_loader = require __DIR__ . '/../../../vendor/autoload.php'; + $class_loader = require DRUPAL_ROOT . '/core/vendor/autoload.php'; Settings::initialize($directory, $class_loader); // Execute the non-interactive installer. diff -u b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php --- b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php +++ b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php @@ -52,7 +52,7 @@ */ protected function getTestKernel(Request $request, array $modules_enabled = NULL, $read_only = FALSE) { // Manually create kernel to avoid replacing settings. - $class_loader = require __DIR__ . '/../../../../../vendor/autoload.php'; + $class_loader = require DRUPAL_ROOT . '/core/vendor/autoload.php'; $kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing'); $this->settingsSet('hash_salt', $this->databasePrefix); if (isset($modules_enabled)) { diff -u b/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php b/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php --- b/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php +++ b/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php @@ -32,7 +32,7 @@ Database::addConnectionInfo('default', 'replica', $connection_info['default']); db_ignore_replica(); - $class_loader = require __DIR__ . '/../../../../../vendor/autoload.php'; + $class_loader = require DRUPAL_ROOT . '/core/vendor/autoload.php'; $kernel = new DrupalKernel('testing', $class_loader, FALSE); $event = new GetResponseEvent($kernel, Request::create('http://example.com'), HttpKernelInterface::MASTER_REQUEST); $subscriber = new ReplicaDatabaseIgnoreSubscriber(); diff -u b/sites/default/default.settings.php b/sites/default/default.settings.php --- b/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -371,32 +371,23 @@ /** * Class Loader. * - * By default, Drupal uses Composer's ClassLoader, which is best for - * development, as it does not break when code is moved on the file - * system. It is possible, however, to wrap the class loader with a - * cached class loader solution for better performance, which is + * By default, Composer's ClassLoader is used, which is best for development, as + * it does not break when code is moved in the file system. You can wrap the + * class loader with a cached solution for better performance, which is * recommended for production sites. * - * For this reason the $class_loader variable is available when this file is - * loaded. + * To do so, you may decorate and replace the local $class_loader variable. * - * To use Symfony's APC class loader, for example, uncomment the code below. - * - * @see \Symfony\Component\ClassLoader\ApcClassLoader + * For example, to use Symfony's APC class loader, uncomment the code below. */ -/** -use Symfony\Component\ClassLoader\ApcClassLoader; - -// Do not do anything if no hash salt is set. +/* if ($settings['hash_salt']) { - // Wrap $class_loader with Symfony's APC class loader. - $apc_loader = new ApcClassLoader('drupal.' . $settings['hash_salt'], $class_loader); + $apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader('drupal.' . $settings['hash_salt'], $class_loader); $class_loader->unregister(); $apc_loader->register(); - // Replace the $class_loader variable. $class_loader = $apc_loader; } - */ +*/ /** * Authorized file system operations: