From 7f93a368025ddfc3edf1cb429b0602938647ac04 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 24 Jan 2022 14:31:35 +0000
Subject: [PATCH] Issue #3209723 by murilohp, daffie, longwave, andypost:
 [Symfony 6] Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST
 is deprecated, use ::MAIN_REQUEST instead

---
 core/lib/Drupal/Core/DrupalKernel.php         |  4 +--
 .../Core/StackMiddleware/KernelPreHandle.php  |  2 +-
 .../StackMiddleware/NegotiationMiddleware.php |  2 +-
 .../ReverseProxyMiddleware.php                |  2 +-
 .../Drupal/Core/StackMiddleware/Session.php   |  6 ++---
 core/lib/Drupal/Core/Update/UpdateKernel.php  |  2 +-
 core/modules/ban/src/BanMiddleware.php        |  2 +-
 .../ban/tests/src/Unit/BanMiddlewareTest.php  |  2 +-
 core/modules/big_pipe/src/Render/BigPipe.php  |  4 +--
 .../src/StackMiddleware/PageCache.php         | 16 +++++------
 .../src/Kernel/EditorIntegrationTest.php      |  2 +-
 .../ResourceResponseSubscriberTest.php        |  6 ++---
 .../DefaultExceptionSubscriberTest.php        |  2 +-
 .../src/AcceptHeaderMiddleware.php            |  2 +-
 .../src/MonkeysInTheControlRoom.php           |  2 +-
 .../StackMiddleware/FormTestMiddleware.php    |  2 +-
 .../src/HttpKernel/TestMiddleware.php         |  2 +-
 .../tests/src/Kernel/TimezoneResolverTest.php |  2 +-
 .../KernelTests/Core/Ajax/CommandsTest.php    |  2 +-
 .../Core/Database/ReplicaKillSwitchTest.php   |  2 +-
 .../Core/Http/BlockInterestCohortTest.php     |  4 +--
 .../HttpKernel/StackKernelIntegrationTest.php |  2 +-
 .../Tests/Core/Ajax/AjaxResponseTest.php      |  2 +-
 .../DrupalKernel/DrupalKernelLegacyTest.php   |  2 +-
 .../ActiveLinkResponseFilterTest.php          |  6 ++---
 .../CustomPageExceptionHtmlSubscriberTest.php |  4 +--
 .../ExceptionJsonSubscriberTest.php           |  2 +-
 .../FinalExceptionSubscriberTest.php          |  2 +-
 .../OptionsRequestSubscriberTest.php          |  6 ++---
 .../PsrResponseSubscriberTest.php             |  2 +-
 .../RssResponseRelativeUrlFilterTest.php      |  2 +-
 .../FormAjaxSubscriberTest.php                |  4 +--
 .../NegotiationMiddlewareTest.php             | 27 ++++++++-----------
 .../ReverseProxyMiddlewareTest.php            | 16 +++--------
 34 files changed, 67 insertions(+), 80 deletions(-)

diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 2eea7f987c64..90fa2fce5a00 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -686,7 +686,7 @@ public function terminate(Request $request, Response $response) {
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     // Ensure sane PHP environment variables.
     static::bootEnvironment();
 
@@ -726,7 +726,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
    * @param \Symfony\Component\HttpFoundation\Request $request
    *   A Request instance
    * @param int $type
-   *   The type of the request (one of HttpKernelInterface::MASTER_REQUEST or
+   *   The type of the request (one of HttpKernelInterface::MAIN_REQUEST or
    *   HttpKernelInterface::SUB_REQUEST)
    *
    * @return \Symfony\Component\HttpFoundation\Response
diff --git a/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php b/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php
index 5df27acc7142..25ff6fc595ed 100644
--- a/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php
+++ b/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php
@@ -42,7 +42,7 @@ public function __construct(HttpKernelInterface $http_kernel, DrupalKernelInterf
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     $this->drupalKernel->preHandle($request);
 
     return $this->httpKernel->handle($request, $type, $catch);
diff --git a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
index ecc6dd61ea1c..37054a6aa0f9 100644
--- a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
+++ b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
@@ -38,7 +38,7 @@ public function __construct(HttpKernelInterface $app) {
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     // Register available mime types.
     foreach ($this->formats as $format => $mime_type) {
       $request->setFormat($format, $mime_type);
diff --git a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
index 69221e798919..9e3c6f77906d 100644
--- a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
+++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
@@ -42,7 +42,7 @@ public function __construct(HttpKernelInterface $http_kernel, Settings $settings
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     // Initialize proxy settings.
     static::setSettingsOnRequest($request, $this->settings);
     return $this->httpKernel->handle($request, $type, $catch);
diff --git a/core/lib/Drupal/Core/StackMiddleware/Session.php b/core/lib/Drupal/Core/StackMiddleware/Session.php
index 8c3eb5d74f0f..d9da60ac6025 100644
--- a/core/lib/Drupal/Core/StackMiddleware/Session.php
+++ b/core/lib/Drupal/Core/StackMiddleware/Session.php
@@ -48,8 +48,8 @@ public function __construct(HttpKernelInterface $http_kernel, $service_name = 's
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
-    if ($type === self::MASTER_REQUEST && PHP_SAPI !== 'cli') {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
+    if ($type === self::MAIN_REQUEST && PHP_SAPI !== 'cli') {
       $session = $this->container->get($this->sessionServiceName);
       $session->start();
       $request->setSession($session);
@@ -57,7 +57,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
 
     $result = $this->httpKernel->handle($request, $type, $catch);
 
-    if ($type === self::MASTER_REQUEST && $request->hasSession()) {
+    if ($type === self::MAIN_REQUEST && $request->hasSession()) {
       $request->getSession()->save();
     }
 
diff --git a/core/lib/Drupal/Core/Update/UpdateKernel.php b/core/lib/Drupal/Core/Update/UpdateKernel.php
index 4a781ff477d2..5a8d8f3d3076 100644
--- a/core/lib/Drupal/Core/Update/UpdateKernel.php
+++ b/core/lib/Drupal/Core/Update/UpdateKernel.php
@@ -55,7 +55,7 @@ protected function cacheDrupalContainer(array $container_definition) {
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     try {
       static::bootEnvironment();
 
diff --git a/core/modules/ban/src/BanMiddleware.php b/core/modules/ban/src/BanMiddleware.php
index dc5b8d4dae00..87d3d6591bba 100644
--- a/core/modules/ban/src/BanMiddleware.php
+++ b/core/modules/ban/src/BanMiddleware.php
@@ -42,7 +42,7 @@ public function __construct(HttpKernelInterface $http_kernel, BanIpManagerInterf
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     $ip = $request->getClientIp();
     if ($this->banIpManager->isBanned($ip)) {
       return new Response(new FormattableMarkup('@ip has been banned', ['@ip' => $ip]), 403);
diff --git a/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php b/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php
index 4b5a0ee27a9b..7f12b37e5dbf 100644
--- a/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php
+++ b/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php
@@ -81,7 +81,7 @@ public function testUnbannedIp() {
     $expected_response = new Response(200);
     $this->kernel->expects($this->once())
       ->method('handle')
-      ->with($request, HttpKernelInterface::MASTER_REQUEST, TRUE)
+      ->with($request, HttpKernelInterface::MAIN_REQUEST, TRUE)
       ->willReturn($expected_response);
 
     $response = $this->banMiddleware->handle($request);
diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php
index 133c86534eb5..985502876338 100644
--- a/core/modules/big_pipe/src/Render/BigPipe.php
+++ b/core/modules/big_pipe/src/Render/BigPipe.php
@@ -637,7 +637,7 @@ protected function filterEmbeddedResponse(Request $fake_request, Response $embed
    *   The request for which a response is being sent.
    * @param int $request_type
    *   The request type. Can either be
-   *   \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST or
+   *   \Symfony\Component\HttpKernel\HttpKernelInterface::MAIN_REQUEST or
    *   \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST.
    * @param \Symfony\Component\HttpFoundation\Response $response
    *   The response to filter.
@@ -646,7 +646,7 @@ protected function filterEmbeddedResponse(Request $fake_request, Response $embed
    *   The filtered response.
    */
   protected function filterResponse(Request $request, $request_type, Response $response) {
-    assert($request_type === HttpKernelInterface::MASTER_REQUEST || $request_type === HttpKernelInterface::SUB_REQUEST);
+    assert($request_type === HttpKernelInterface::MAIN_REQUEST || $request_type === HttpKernelInterface::SUB_REQUEST);
     $this->requestStack->push($request);
     $event = new ResponseEvent($this->httpKernel, $request, $request_type, $response);
     $this->eventDispatcher->dispatch($event, KernelEvents::RESPONSE);
diff --git a/core/modules/page_cache/src/StackMiddleware/PageCache.php b/core/modules/page_cache/src/StackMiddleware/PageCache.php
index 2c425657fbcf..05a70187e1ad 100644
--- a/core/modules/page_cache/src/StackMiddleware/PageCache.php
+++ b/core/modules/page_cache/src/StackMiddleware/PageCache.php
@@ -76,9 +76,9 @@ public function __construct(HttpKernelInterface $http_kernel, CacheBackendInterf
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     // Only allow page caching on master request.
-    if ($type === static::MASTER_REQUEST && $this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW) {
+    if ($type === static::MAIN_REQUEST && $this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW) {
       $response = $this->lookup($request, $type, $catch);
     }
     else {
@@ -94,7 +94,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
    * @param \Symfony\Component\HttpFoundation\Request $request
    *   A request object.
    * @param int $type
-   *   The type of the request (one of HttpKernelInterface::MASTER_REQUEST or
+   *   The type of the request (one of HttpKernelInterface::MAIN_REQUEST or
    *   HttpKernelInterface::SUB_REQUEST)
    * @param bool $catch
    *   Whether to catch exceptions or not
@@ -102,7 +102,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
    * @returns \Symfony\Component\HttpFoundation\Response $response
    *   A response object.
    */
-  protected function pass(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
+  protected function pass(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) {
     return $this->httpKernel->handle($request, $type, $catch);
   }
 
@@ -112,7 +112,7 @@ protected function pass(Request $request, $type = self::MASTER_REQUEST, $catch =
    * @param \Symfony\Component\HttpFoundation\Request $request
    *   A request object.
    * @param int $type
-   *   The type of the request (one of HttpKernelInterface::MASTER_REQUEST or
+   *   The type of the request (one of HttpKernelInterface::MAIN_REQUEST or
    *   HttpKernelInterface::SUB_REQUEST)
    * @param bool $catch
    *   Whether to catch exceptions or not
@@ -120,7 +120,7 @@ protected function pass(Request $request, $type = self::MASTER_REQUEST, $catch =
    * @returns \Symfony\Component\HttpFoundation\Response $response
    *   A response object.
    */
-  protected function lookup(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
+  protected function lookup(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) {
     if ($response = $this->get($request)) {
       $response->headers->set('X-Drupal-Cache', 'HIT');
     }
@@ -178,7 +178,7 @@ protected function lookup(Request $request, $type = self::MASTER_REQUEST, $catch
    * @param \Symfony\Component\HttpFoundation\Request $request
    *   A request object.
    * @param int $type
-   *   The type of the request (one of HttpKernelInterface::MASTER_REQUEST or
+   *   The type of the request (one of HttpKernelInterface::MAIN_REQUEST or
    *   HttpKernelInterface::SUB_REQUEST)
    * @param bool $catch
    *   Whether to catch exceptions or not
@@ -186,7 +186,7 @@ protected function lookup(Request $request, $type = self::MASTER_REQUEST, $catch
    * @returns \Symfony\Component\HttpFoundation\Response $response
    *   A response object.
    */
-  protected function fetch(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
+  protected function fetch(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) {
     /** @var \Symfony\Component\HttpFoundation\Response $response */
     $response = $this->httpKernel->handle($request, $type, $catch);
 
diff --git a/core/modules/quickedit/tests/src/Kernel/EditorIntegrationTest.php b/core/modules/quickedit/tests/src/Kernel/EditorIntegrationTest.php
index 6852bafdb5ea..4dd1bd037655 100644
--- a/core/modules/quickedit/tests/src/Kernel/EditorIntegrationTest.php
+++ b/core/modules/quickedit/tests/src/Kernel/EditorIntegrationTest.php
@@ -235,7 +235,7 @@ public function testGetUntransformedTextCommand() {
     $event = new ResponseEvent(
       \Drupal::service('http_kernel'),
       $request,
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       $response
     );
     $subscriber->onResponse($event);
diff --git a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
index 8ff2eae36ef7..44f5d55dc4a4 100644
--- a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
+++ b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
@@ -42,7 +42,7 @@ public function testSerialization($data, $expected_response = FALSE) {
     $event = new ResponseEvent(
       $this->prophesize(HttpKernelInterface::class)->reveal(),
       $request,
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       $handler_response
     );
     $resource_response_subscriber->onResponse($event);
@@ -146,7 +146,7 @@ public function testOnResponseWithCacheableResponse($methods, array $supported_r
       $event = new ResponseEvent(
         $this->prophesize(HttpKernelInterface::class)->reveal(),
         $request,
-        HttpKernelInterface::MASTER_REQUEST,
+        HttpKernelInterface::MAIN_REQUEST,
         $handler_response
       );
       $resource_response_subscriber->onResponse($event);
@@ -196,7 +196,7 @@ public function testOnResponseWithUncacheableResponse($methods, array $supported
       $event = new ResponseEvent(
         $this->prophesize(HttpKernelInterface::class)->reveal(),
         $request,
-        HttpKernelInterface::MASTER_REQUEST,
+        HttpKernelInterface::MAIN_REQUEST,
         $handler_response
       );
       $resource_response_subscriber->onResponse($event);
diff --git a/core/modules/serialization/tests/src/Unit/EventSubscriber/DefaultExceptionSubscriberTest.php b/core/modules/serialization/tests/src/Unit/EventSubscriber/DefaultExceptionSubscriberTest.php
index 840de7e5ff26..ed09e27fc1cb 100644
--- a/core/modules/serialization/tests/src/Unit/EventSubscriber/DefaultExceptionSubscriberTest.php
+++ b/core/modules/serialization/tests/src/Unit/EventSubscriber/DefaultExceptionSubscriberTest.php
@@ -27,7 +27,7 @@ public function testOn4xx() {
     $request->setRequestFormat('json');
 
     $e = new MethodNotAllowedHttpException(['POST', 'PUT'], 'test message');
-    $event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $e);
+    $event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MAIN_REQUEST, $e);
     $subscriber = new DefaultExceptionSubscriber(new Serializer([], [new JsonEncoder()]), []);
     $subscriber->on4xx($event);
     $response = $event->getResponse();
diff --git a/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderMiddleware.php b/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderMiddleware.php
index 45f2bb7c5813..371fa0f46c7a 100644
--- a/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderMiddleware.php
+++ b/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderMiddleware.php
@@ -24,7 +24,7 @@ public function __construct(HttpKernelInterface $app) {
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     $mapping = [
       'application/json' => 'json',
       'application/hal+json' => 'hal_json',
diff --git a/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php b/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php
index 304d8ed93b6e..7df8d810f927 100644
--- a/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php
+++ b/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php
@@ -37,7 +37,7 @@ public function __construct(HttpKernelInterface $app, Settings $settings) {
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     if (\Drupal::state()->get('error_service_test.break_bare_html_renderer')) {
       // Let the bedlam begin.
       // 1) Force a container rebuild.
diff --git a/core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php b/core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php
index 3db45b9c400c..ca23b1417b07 100644
--- a/core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php
+++ b/core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php
@@ -31,7 +31,7 @@ public function __construct(HttpKernelInterface $http_kernel) {
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     $response = $this->httpKernel->handle($request, $type, $catch);
     $response->headers->set('X-Form-Test-Stack-Middleware', 'invoked');
     return $response;
diff --git a/core/modules/system/tests/modules/httpkernel_test/src/HttpKernel/TestMiddleware.php b/core/modules/system/tests/modules/httpkernel_test/src/HttpKernel/TestMiddleware.php
index 5bf54c3d9d47..8cab8452f5c3 100644
--- a/core/modules/system/tests/modules/httpkernel_test/src/HttpKernel/TestMiddleware.php
+++ b/core/modules/system/tests/modules/httpkernel_test/src/HttpKernel/TestMiddleware.php
@@ -41,7 +41,7 @@ public function __construct(HttpKernelInterface $kernel, $optional_argument = NU
   /**
    * {@inheritdoc}
    */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
+  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     $request->attributes->set('_hello', 'world');
     if ($request->attributes->has('_optional_argument')) {
       $request->attributes->set('_previous_optional_argument', $request->attributes->get('_optional_argument'));
diff --git a/core/modules/system/tests/src/Kernel/TimezoneResolverTest.php b/core/modules/system/tests/src/Kernel/TimezoneResolverTest.php
index d9a29332e5e6..ae7701f4702e 100644
--- a/core/modules/system/tests/src/Kernel/TimezoneResolverTest.php
+++ b/core/modules/system/tests/src/Kernel/TimezoneResolverTest.php
@@ -45,7 +45,7 @@ public function testGetTimeZone() {
     $eventDispatcher = $this->container->get('event_dispatcher');
     $kernel = $this->container->get('kernel');
 
-    $eventDispatcher->dispatch(new RequestEvent($kernel, Request::create('http://www.example.com'), HttpKernelInterface::MASTER_REQUEST, KernelEvents::REQUEST));
+    $eventDispatcher->dispatch(new RequestEvent($kernel, Request::create('http://www.example.com'), HttpKernelInterface::MAIN_REQUEST, KernelEvents::REQUEST));
 
     $this->assertEquals('Australia/Adelaide', date_default_timezone_get());
 
diff --git a/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php b/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php
index 487f3c6cd47b..b4480f160bb6 100644
--- a/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php
@@ -43,7 +43,7 @@ public function testAttachedSettings() {
       $event = new ResponseEvent(
         \Drupal::service('http_kernel'),
         new Request(),
-        HttpKernelInterface::MASTER_REQUEST,
+        HttpKernelInterface::MAIN_REQUEST,
         $response
       );
       $subscriber->onResponse($event);
diff --git a/core/tests/Drupal/KernelTests/Core/Database/ReplicaKillSwitchTest.php b/core/tests/Drupal/KernelTests/Core/Database/ReplicaKillSwitchTest.php
index 7df3f5979e74..e37eae88c944 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/ReplicaKillSwitchTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/ReplicaKillSwitchTest.php
@@ -32,7 +32,7 @@ public function testSystemInitIgnoresSecondaries() {
     $service->trigger();
     $class_loader = require $this->root . '/autoload.php';
     $kernel = new DrupalKernel('testing', $class_loader, FALSE);
-    $event = new RequestEvent($kernel, Request::create('http://example.com'), HttpKernelInterface::MASTER_REQUEST);
+    $event = new RequestEvent($kernel, Request::create('http://example.com'), HttpKernelInterface::MAIN_REQUEST);
     $service->checkReplicaServer($event);
 
     $db1 = Database::getConnection('default', 'default');
diff --git a/core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php b/core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php
index d1267ae5aa68..10a7b0043894 100644
--- a/core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php
@@ -35,7 +35,7 @@ public function testExistingInterestCohortPolicy() {
     $kernel = \Drupal::service('http_kernel');
     $request = Request::create('/');
     $response = new Response('', 200, $headers);
-    $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
+    $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response);
     \Drupal::service('finish_response_subscriber')->onRespond($event);
 
     $this->assertSame($headers['Permissions-Policy'], $response->headers->get('Permissions-Policy'));
@@ -50,7 +50,7 @@ public function testExistingPolicyHeader() {
     $kernel = \Drupal::service('http_kernel');
     $request = Request::create('/');
     $response = new Response('', 200, $headers);
-    $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
+    $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response);
     \Drupal::service('finish_response_subscriber')->onRespond($event);
 
     $this->assertSame($headers['Permissions-Policy'], $response->headers->get('Permissions-Policy'));
diff --git a/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php
index fc9c74ba7cc7..6dee2fabcc3f 100644
--- a/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php
@@ -28,7 +28,7 @@ public function testRequest() {
     $request = Request::create((new Url('httpkernel_test.empty'))->toString());
     /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */
     $http_kernel = \Drupal::service('http_kernel');
-    $http_kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, FALSE);
+    $http_kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, FALSE);
 
     $this->assertEquals('world', $request->attributes->get('_hello'));
     $this->assertEquals('test_argument', $request->attributes->get('_previous_optional_argument'));
diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
index 2e2b93532bde..050a63822e84 100644
--- a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
+++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
@@ -83,7 +83,7 @@ public function testPrepareResponseForIeFormRequestsWithFileUpload() {
     $event = new ResponseEvent(
       $this->createMock('\Symfony\Component\HttpKernel\HttpKernelInterface'),
       $request,
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       $response
     );
     $subscriber->onResponse($event);
diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelLegacyTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelLegacyTest.php
index 9afef566f4fa..f6034c35ad7e 100644
--- a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelLegacyTest.php
+++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelLegacyTest.php
@@ -21,7 +21,7 @@ class DrupalKernelLegacyTest extends UnitTestCase {
   public function testKernelEventDeprecation() {
     $kernel = $this->createMock(DrupalKernel::class);
     $request = $this->createMock(Request::class);
-    $event = new KernelEvent($kernel, $request, $kernel::MASTER_REQUEST);
+    $event = new KernelEvent($kernel, $request, $kernel::MAIN_REQUEST);
 
     $this->expectDeprecation('Since symfony/http-kernel 5.3: "Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest()" is deprecated, use "isMainRequest()" instead.');
     $this->assertTrue($event->isMasterRequest());
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
index 6d3be86b9b11..5e5b06cfcc8f 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
@@ -444,7 +444,7 @@ public function testOnlyHtml() {
     $subscriber->onResponse(new ResponseEvent(
       $this->prophesize(KernelInterface::class)->reveal(),
       $request_stack->getCurrentRequest(),
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       $response
     ));
     $this->assertSame($response->getContent(), $content);
@@ -480,7 +480,7 @@ public function testSkipCertainResponseTypes() {
     $subscriber->onResponse(new ResponseEvent(
       $this->prophesize(KernelInterface::class)->reveal(),
       $request_stack->getCurrentRequest(),
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       $response
     ));
 
@@ -492,7 +492,7 @@ public function testSkipCertainResponseTypes() {
     $subscriber->onResponse(new ResponseEvent(
       $this->prophesize(KernelInterface::class)->reveal(),
       $request_stack->getCurrentRequest(),
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       $response
     ));
   }
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php
index 5367e6523b54..964220206cc4 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php
@@ -139,7 +139,7 @@ public function testHandleWithPostRequest() {
       return new HtmlResponse($request->getMethod());
     });
 
-    $event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo'));
+    $event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MAIN_REQUEST, new NotFoundHttpException('foo'));
 
     $this->customPageSubscriber->onException($event);
 
@@ -166,7 +166,7 @@ public function testHandleWithGetRequest() {
       return new Response($request->getMethod() . ' ' . UrlHelper::buildQuery($request->query->all()));
     });
 
-    $event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo'));
+    $event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MAIN_REQUEST, new NotFoundHttpException('foo'));
     $this->customPageSubscriber->onException($event);
 
     $response = $event->getResponse();
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php
index 57d62d14ece9..c8a33bce0a72 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php
@@ -27,7 +27,7 @@ class ExceptionJsonSubscriberTest extends UnitTestCase {
   public function testOn4xx(HttpExceptionInterface $exception, $expected_response_class) {
     $kernel = $this->prophesize(HttpKernelInterface::class);
     $request = Request::create('/test');
-    $event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $exception);
+    $event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MAIN_REQUEST, $exception);
     $subscriber = new ExceptionJsonSubscriber();
     $subscriber->on4xx($event);
     $response = $event->getResponse();
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php
index 62bccf497126..4b6bc941e69b 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php
@@ -28,7 +28,7 @@ public function testOnExceptionWithUnknownFormat() {
     // of this so we'll hard code it here.
     $request->setRequestFormat('bananas');
     $e = new MethodNotAllowedHttpException(['POST', 'PUT'], 'test message');
-    $event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $e);
+    $event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MAIN_REQUEST, $e);
     $subscriber = new TestDefaultExceptionSubscriber($config_factory);
     $subscriber->setStringTranslation($this->getStringTranslationStub());
     $subscriber->onException($event);
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php
index 6a2e7b6fd790..bcc51bb8abad 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php
@@ -28,7 +28,7 @@ public function testWithNonOptionRequest() {
     $route_provider->getRouteCollectionForRequest($request)->shouldNotBeCalled();
 
     $subscriber = new OptionsRequestSubscriber($route_provider->reveal());
-    $event = new RequestEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST);
+    $event = new RequestEvent($kernel->reveal(), $request, HttpKernelInterface::MAIN_REQUEST);
     $subscriber->onRequest($event);
 
     $this->assertFalse($event->hasResponse());
@@ -45,7 +45,7 @@ public function testWithoutMatchingRoutes() {
     $route_provider->getRouteCollectionForRequest($request)->willReturn(new RouteCollection())->shouldBeCalled();
 
     $subscriber = new OptionsRequestSubscriber($route_provider->reveal());
-    $event = new RequestEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST);
+    $event = new RequestEvent($kernel->reveal(), $request, HttpKernelInterface::MAIN_REQUEST);
     $subscriber->onRequest($event);
 
     $this->assertFalse($event->hasResponse());
@@ -63,7 +63,7 @@ public function testWithOptionsRequest(RouteCollection $collection, $expected_he
     $route_provider->getRouteCollectionForRequest($request)->willReturn($collection)->shouldBeCalled();
 
     $subscriber = new OptionsRequestSubscriber($route_provider->reveal());
-    $event = new RequestEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST);
+    $event = new RequestEvent($kernel->reveal(), $request, HttpKernelInterface::MAIN_REQUEST);
     $subscriber->onRequest($event);
 
     $this->assertTrue($event->hasResponse());
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php
index 7b166944761c..0abce89cd52a 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php
@@ -85,7 +85,7 @@ protected function createEvent($controller_result) {
     return new ViewEvent(
       $this->createMock(HttpKernelInterface::class),
       $this->createMock(Request::class),
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       $controller_result
     );
   }
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php
index 92d85f05310b..fe0dd1d170f5 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php
@@ -116,7 +116,7 @@ public function testOnResponse($content, $expected_content) {
     $event = new ResponseEvent(
       $this->prophesize(HttpKernelInterface::class)->reveal(),
       Request::create('/'),
-      HttpKernelInterface::MASTER_REQUEST,
+      HttpKernelInterface::MAIN_REQUEST,
       new Response($content, 200, [
         'Content-Type' => 'application/rss+xml',
       ])
diff --git a/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
index 1f51ed6f40a5..90581d843596 100644
--- a/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
@@ -198,7 +198,7 @@ public function testOnExceptionBrokenPostRequest() {
     $exception = new BrokenPostRequestException(32 * 1e6);
     $request = new Request([FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]);
 
-    $event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception);
+    $event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MAIN_REQUEST, $exception);
     $this->subscriber->onException($event);
     $this->assertTrue($event->isAllowingCustomResponseCode());
     $actual_response = $event->getResponse();
@@ -266,7 +266,7 @@ public function testOnExceptionNestedWrongException() {
    * @internal
    */
   protected function assertResponseFromException(Request $request, \Exception $exception, ?Response $expected_response): void {
-    $this->event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception);
+    $this->event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MAIN_REQUEST, $exception);
     $this->subscriber->onException($this->event);
 
     $this->assertSame($expected_response, $this->event->getResponse());
diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php
index bd1137de8495..1af7579f91cd 100644
--- a/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php
+++ b/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php
@@ -36,7 +36,7 @@ class NegotiationMiddlewareTest extends UnitTestCase {
   protected function setUp(): void {
     parent::setUp();
 
-    $this->app = $this->prophesize(MockedHttpKernelInterface::class);
+    $this->app = $this->prophesize(HttpKernelInterface::class);
     $this->contentNegotiation = new StubNegotiationMiddleware($this->app->reveal());
   }
 
@@ -109,12 +109,18 @@ public function testHandle() {
     $request_mock->request = $request_data->reveal();
 
     // Calling kernel app with default arguments.
-    $this->app->handle($request_mock, HttpKernelInterface::MASTER_REQUEST, TRUE)
-      ->shouldBeCalled();
+    $this->app->handle($request_mock, HttpKernelInterface::MAIN_REQUEST, TRUE)
+      ->shouldBeCalled()
+      ->willReturn(
+        $this->createMock(Response::class)
+      );
     $this->contentNegotiation->handle($request_mock);
     // Calling kernel app with specified arguments.
     $this->app->handle($request_mock, HttpKernelInterface::SUB_REQUEST, FALSE)
-      ->shouldBeCalled();
+      ->shouldBeCalled()
+      ->willReturn(
+        $this->createMock(Response::class)
+      );
     $this->contentNegotiation->handle($request_mock, HttpKernelInterface::SUB_REQUEST, FALSE);
   }
 
@@ -122,7 +128,7 @@ public function testHandle() {
    * @covers ::registerFormat
    */
   public function testSetFormat() {
-    $app = $this->createMock(MockedHttpKernelInterface::class);
+    $app = $this->createMock(HttpKernelInterface::class);
     $app->expects($this->once())
       ->method('handle')
       ->will($this->returnValue($this->createMock(Response::class)));
@@ -156,14 +162,3 @@ public function getContentType(Request $request) {
   }
 
 }
-
-/**
- * Helper interface for the Symfony 6 version of the HttpKernelInterface.
- *
- * @todo Remove this interface when the Symfony 6 is in core.
- */
-interface MockedHttpKernelInterface extends HttpKernelInterface {
-
-  public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = TRUE): Response;
-
-}
diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
index 9823175f7112..406c56079bc1 100644
--- a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
+++ b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
@@ -25,7 +25,10 @@ class ReverseProxyMiddlewareTest extends UnitTestCase {
    * {@inheritdoc}
    */
   protected function setUp(): void {
-    $this->mockHttpKernel = $this->createMock(MockHttpKernelInterface::class);
+    $responseMock = $this->createMock(Response::class);
+    $this->mockHttpKernel = $this->createMock(HttpKernelInterface::class);
+    $this->mockHttpKernel->method('handle')
+      ->willReturn($responseMock);
   }
 
   /**
@@ -106,14 +109,3 @@ protected function trustedHeadersAreSet(Settings $settings, $expected_trusted_he
   }
 
 }
-
-/**
- * Helper interface for the Symfony 6 version of the HttpKernelInterface.
- *
- * @todo Remove this interface when the Symfony 6 is in core.
- */
-interface MockHttpKernelInterface extends HttpKernelInterface {
-
-  public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = TRUE): Response;
-
-}
-- 
GitLab