diff --git a/core/core.services.yml b/core/core.services.yml index d8a4a5b94e..6b972c88d4 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -743,7 +743,7 @@ services: class: Drupal\Core\StackMiddleware\StackedHttpKernel http_kernel.basic: class: Symfony\Component\HttpKernel\HttpKernel - arguments: ['@event_dispatcher', '@controller_resolver', '@request_stack', '@http_kernel.controller.argument_resolver', false] + arguments: ['@event_dispatcher', '@controller_resolver', '@request_stack', '@http_kernel.controller.argument_resolver', true] http_kernel.controller.argument_resolver: class: Symfony\Component\HttpKernel\Controller\ArgumentResolver arguments: ['@http_kernel.controller.argument_metadata_factory', ['@argument_resolver.request_attribute', '@argument_resolver.request', '@argument_resolver.psr7_request', '@argument_resolver.route_match', '@argument_resolver.default']] 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 2d08efc6fc..cef5bb64b8 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 @@ -67,20 +67,7 @@ public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TR throw new \Exception('Deforestation'); } - if ($this->settings->get('teapots', FALSE) && class_exists('\TypeError')) { - try { - $return = $this->app->handle($request, $type, $catch); - } - catch (\TypeError $e) { - header('HTTP/1.1 418 I\'m a teapot'); - print('Oh oh, flying teapots'); - exit; - } - } - else { - $return = $this->app->handle($request, $type, $catch); - } - return $return; + return $this->app->handle($request, $type, $catch); } } diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php index 26daf6ec1c..e9007b51d5 100644 --- a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php +++ b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php @@ -92,6 +92,30 @@ public function testErrorHandler() { $this->assertSession()->responseNotContains('
');
   }
 
+  /**
+   * Tests a custom error handler set in settings.php.
+   */
+  public function testCustomErrorHandler() {
+    $settings_filename = $this->siteDirectory . '/settings.php';
+    chmod($settings_filename, 0777);
+    $settings_php = file_get_contents($settings_filename);
+    $settings_php .= "\n";
+    $settings_php .= "set_error_handler(function() {\n";
+    $settings_php .= "  header('HTTP/1.1 418 I\'m a teapot');\n";
+    $settings_php .= "  print('Oh oh, flying teapots from a custom error handler');\n";
+    $settings_php .= "  exit();\n";
+    $settings_php .= "});\n";
+    file_put_contents($settings_filename, $settings_php);
+
+    // For most types of errors, PHP throws an \Error object that Drupal
+    // catches, so the error handler is not invoked. To test the error handler,
+    // generate warnings, which are not thrown/caught.
+    $this->drupalGet('error-test/generate-warnings');
+
+    $this->assertSession()->statusCodeEquals(418);
+    $this->assertSession()->responseContains('Oh oh, flying teapots from a custom error handler');
+  }
+
   /**
    * Tests the exception handler.
    */
diff --git a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php
index b03e000b48..fbf557fb1b 100644
--- a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php
+++ b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php
@@ -143,27 +143,6 @@ public function testMissingDependency() {
     $this->assertErrorLogged($this->expectedExceptionMessage);
   }
 
-  /**
-   * Tests a missing dependency on a service with a custom error handler.
-   */
-  public function testMissingDependencyCustomErrorHandler() {
-    $settings_filename = $this->siteDirectory . '/settings.php';
-    chmod($settings_filename, 0777);
-    $settings_php = file_get_contents($settings_filename);
-    $settings_php .= "\n";
-    $settings_php .= "set_error_handler(function() {\n";
-    $settings_php .= "  header('HTTP/1.1 418 I\'m a teapot');\n";
-    $settings_php .= "  print('Oh oh, flying teapots');\n";
-    $settings_php .= "  exit();\n";
-    $settings_php .= "});\n";
-    $settings_php .= "\$settings['teapots'] = TRUE;\n";
-    file_put_contents($settings_filename, $settings_php);
-
-    $this->drupalGet('broken-service-class');
-    $this->assertSession()->statusCodeEquals(418);
-    $this->assertSession()->responseContains('Oh oh, flying teapots');
-  }
-
   /**
    * Tests a container which has an error.
    */