From 305f249321ea507cb65066b530b46acac34aeae4 Mon Sep 17 00:00:00 2001 From: Jorrit Schippers Date: Fri, 6 Sep 2024 13:13:04 +0200 Subject: [PATCH] Handle error suppression in PHP 8+ In PHP 8 error_reporting() is set to E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE when the error handler is called for suppressed errors. --- includes/common.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/common.inc b/includes/common.inc index 0c6af87217..c142aa28fb 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -698,7 +698,13 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = function drupal_error_handler($errno, $message, $filename, $line, $context = NULL) { // If the @ error suppression operator was used, error_reporting will have // been temporarily set to 0. - if (error_reporting() == 0) { + // If the @ error suppression operator was used, error_reporting will have + // been temporarily set to 0. + if (PHP_MAJOR_VERSION <= 7 && error_reporting() == 0) { + return; + } + // In PHP 8, it is set to E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE when using @. + if (PHP_MAJOR_VERSION >= 8 && error_reporting() === (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE)) { return; }