Loading core/core.services.yml +1 −1 Changes for core/core.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -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']] Loading core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php +1 −14 Changes for core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php: 1 added line, 14 removed lines. Original line number Diff line number Diff line Loading @@ -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); } } core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php +24 −0 Changes for core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -92,6 +92,30 @@ public function testErrorHandler() { $this->assertSession()->responseNotContains('<pre class="backtrace">'); } /** * 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. */ Loading core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php +0 −21 Changes for core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php: 0 added lines, 21 removed lines. Original line number Diff line number Diff line Loading @@ -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. */ Loading Loading
core/core.services.yml +1 −1 Changes for core/core.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -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']] Loading
core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php +1 −14 Changes for core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php: 1 added line, 14 removed lines. Original line number Diff line number Diff line Loading @@ -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); } }
core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php +24 −0 Changes for core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -92,6 +92,30 @@ public function testErrorHandler() { $this->assertSession()->responseNotContains('<pre class="backtrace">'); } /** * 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. */ Loading
core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php +0 −21 Changes for core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php: 0 added lines, 21 removed lines. Original line number Diff line number Diff line Loading @@ -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. */ Loading