X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FDrupalKernel.php;h=fec1be9ad3a6163744a6cfde69965417b3121608;hb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;hp=fc36f6644bd934b04528830fc210a3e0f4b486b7;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/DrupalKernel.php b/web/core/lib/Drupal/Core/DrupalKernel.php index fc36f6644..fec1be9ad 100644 --- a/web/core/lib/Drupal/Core/DrupalKernel.php +++ b/web/core/lib/Drupal/Core/DrupalKernel.php @@ -7,6 +7,7 @@ use Drupal\Component\Assertion\Handle; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; +use Drupal\Core\Cache\DatabaseBackend; use Drupal\Core\Config\BootstrapConfigStorageFactory; use Drupal\Core\Config\NullStorage; use Drupal\Core\Database\Database; @@ -19,6 +20,7 @@ use Drupal\Core\File\MimeType\MimeTypeGuesser; use Drupal\Core\Http\TrustedHostsRequestFactory; use Drupal\Core\Installer\InstallerRedirectTrait; use Drupal\Core\Language\Language; +use Drupal\Core\Security\RequestSanitizer; use Drupal\Core\Site\Settings; use Drupal\Core\Test\TestDatabase; use Symfony\Cmf\Component\Routing\RouteObjectInterface; @@ -77,7 +79,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { ], 'cache.container' => [ 'class' => 'Drupal\Core\Cache\DatabaseBackend', - 'arguments' => ['@database', '@cache_tags_provider.container', 'container'], + 'arguments' => ['@database', '@cache_tags_provider.container', 'container', DatabaseBackend::MAXIMUM_NONE], ], 'cache_tags_provider.container' => [ 'class' => 'Drupal\Core\Cache\DatabaseCacheTagsChecksum', @@ -410,7 +412,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { * {@inheritdoc} */ public function setSitePath($path) { - if ($this->booted) { + if ($this->booted && $path !== $this->sitePath) { throw new \LogicException('Site path cannot be changed after calling boot()'); } $this->sitePath = $path; @@ -541,6 +543,12 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { * {@inheritdoc} */ public function preHandle(Request $request) { + // Sanitize the request. + $request = RequestSanitizer::sanitize( + $request, + (array) Settings::get(RequestSanitizer::SANITIZE_WHITELIST, []), + (bool) Settings::get(RequestSanitizer::SANITIZE_LOG, FALSE) + ); $this->loadLegacyIncludes(); @@ -675,13 +683,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { * * @param \Exception $e * An exception - * @param Request $request + * @param \Symfony\Component\HttpFoundation\Request $request * A Request instance * @param int $type * The type of the request (one of HttpKernelInterface::MASTER_REQUEST or * HttpKernelInterface::SUB_REQUEST) * - * @return Response + * @return \Symfony\Component\HttpFoundation\Response * A Response instance * * @throws \Exception @@ -916,6 +924,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { // new session into the master request if one was present before. if (($request_stack = $this->container->get('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE))) { if ($request = $request_stack->getMasterRequest()) { + $subrequest = TRUE; if ($request->hasSession()) { $request->setSession($this->container->get('session')); } @@ -928,6 +937,12 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { \Drupal::setContainer($this->container); + // Allow other parts of the codebase to react on container initialization in + // subrequest. + if (!empty($subrequest)) { + $this->container->get('event_dispatcher')->dispatch(self::CONTAINER_INITIALIZE_SUBREQUEST_FINISHED); + } + // If needs dumping flag was set, dump the container. if ($this->containerNeedsDumping && !$this->cacheDrupalContainer($container_definition)) { $this->container->get('logger.factory')->get('DrupalKernel')->error('Container cannot be saved to cache.'); @@ -1179,10 +1194,10 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { /** * Attach synthetic values on to kernel. * - * @param ContainerInterface $container + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * Container object * - * @return ContainerInterface + * @return \Symfony\Component\DependencyInjection\ContainerInterface */ protected function attachSynthetic(ContainerInterface $container) { $persist = []; @@ -1205,7 +1220,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { /** * Compiles a new service container. * - * @return ContainerBuilder The compiled service container + * @return \Drupal\Core\DependencyInjection\ContainerBuilder The compiled service container */ protected function compileContainer() { // We are forcing a container build so it is reasonable to assume that the @@ -1326,7 +1341,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { /** * Gets a new ContainerBuilder instance used to build the service container. * - * @return ContainerBuilder + * @return \Drupal\Core\DependencyInjection\ContainerBuilder */ protected function getContainerBuilder() { return new ContainerBuilder(new ParameterBag($this->getKernelParameters()));