E_DEPRECATED warnings makes functional tests fail

Created on 9 August 2024, 7 months ago

Problem/Motivation

After upgrading to 10.3.2 our functional test suites started to break on PHP 8.1 with an exception triggered by an E_DEPRECATED level of warning.

Exception: Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated
Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase::mimeTypeApplies()() (Line: 171)


/mnt/files/local_mount/build/web/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:55
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/Promise.php:209
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/Promise.php:158
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/TaskQueue.php:52
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/Promise.php:251
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/Promise.php:227
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/Promise.php:272
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/Promise.php:229
/mnt/files/local_mount/build/vendor/guzzlehttp/promises/src/Promise.php:69
/mnt/files/local_mount/build/vendor/guzzlehttp/guzzle/src/Client.php:189
/mnt/files/local_mount/build/web/core/tests/Drupal/Tests/DrupalTestBrowser.php:139
/mnt/files/local_mount/build/vendor/symfony/browser-kit/AbstractBrowser.php:385
/mnt/files/local_mount/build/vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php:122
/mnt/files/local_mount/build/vendor/behat/mink/src/Session.php:175
/mnt/files/local_mount/build/web/core/tests/Drupal/Tests/UiHelperTrait.php:260
/mnt/files/local_mount/drupal/modules/foo/tests/src/Functional/Bar.php:66

It seems that currently there is no (good) way to fix this problem because E_DEPRECATED level warnings ALWAYS triggers and exception via \_drupal_log_error() line 162:

  // When running inside the testing framework, we relay the errors
  // to the tested site by the way of HTTP headers.
  if (DRUPAL_TEST_IN_CHILD_SITE && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
    _drupal_error_header($error['@message'], $error['%type'], $error['%function'], $error['%file'], $error['%line']);
  }

SYMFONY_DEPRECATIONS_HELPER=disabled has no impact on this because the exception is triggered and caught by the browser in the test.

In 🐛 Drupal overriding error_reporting setting in php.ini Needs work we already started to explore the issues with Drupal core's current error handling configuration and how it makes environment specific overrides complicated.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
PHPUnit 

Last updated 2 days ago

Created by

🇭🇺Hungary mxr576 Hungary

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024