diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 284d1835e9..19676be9f7 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -58,7 +58,9 @@ function drupal_error_levels() { * occurred. */ function _drupal_error_handler_real($error_level, $message, $filename, $line, $context) { - if ($error_level & error_reporting()) { + // If the site is a test site then fail for user deprecations so they can be + // caught by the deprecation error handler. + if (($error_level & error_reporting()) || (DRUPAL_TEST_IN_CHILD_SITE && $error_level === E_USER_DEPRECATED)) { $types = drupal_error_levels(); list($severity_msg, $severity_level) = $types[$error_level]; $backtrace = debug_backtrace(); diff --git a/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php index 3c4d1427a8..86e9311d45 100644 --- a/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php +++ b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php @@ -41,7 +41,14 @@ public function __invoke() { // the header. $parameters = unserialize(urldecode($header_value)); if (count($parameters) === 3) { - throw new \Exception($parameters[1] . ': ' . $parameters[0] . "\n" . Error::formatBacktrace([$parameters[2]])); + if ($parameters[1] === 'User deprecated function') { + // Fire the same deprecation message to allow it to be + // caught. + @trigger_error((string) $parameters[0], E_USER_DEPRECATED); + } + else { + throw new \Exception($parameters[1] . ': ' . $parameters[0] . "\n" . Error::formatBacktrace([$parameters[2]])); + } } else { throw new \Exception('Error thrown with the wrong amount of parameters.'); diff --git a/core/modules/system/tests/modules/deprecation_test/deprecation_test.module b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module index fd1092a3c6..e255021d65 100644 --- a/core/modules/system/tests/modules/deprecation_test/deprecation_test.module +++ b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module @@ -1,5 +1,10 @@ drupalGet(Url::fromRoute('deprecation_test.route'));