Issue #3173888 by andypost, alexpott, Gábor Hojtsy: Error handler signature changed in PHP 8
parent
a5665ea228
commit
e9969b0f35
|
@ -299,13 +299,10 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
|
||||||
* (optional) The filename that the error was raised in.
|
* (optional) The filename that the error was raised in.
|
||||||
* @param $line
|
* @param $line
|
||||||
* (optional) The line number the error was raised at.
|
* (optional) The line number the error was raised at.
|
||||||
* @param $context
|
|
||||||
* (optional) An array that points to the active symbol table at the point the
|
|
||||||
* error occurred.
|
|
||||||
*/
|
*/
|
||||||
function _drupal_error_handler($error_level, $message, $filename = NULL, $line = NULL, $context = NULL) {
|
function _drupal_error_handler($error_level, $message, $filename = NULL, $line = NULL) {
|
||||||
require_once __DIR__ . '/errors.inc';
|
require_once __DIR__ . '/errors.inc';
|
||||||
_drupal_error_handler_real($error_level, $message, $filename, $line, $context);
|
_drupal_error_handler_real($error_level, $message, $filename, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,11 +54,8 @@ function drupal_error_levels() {
|
||||||
* The filename that the error was raised in.
|
* The filename that the error was raised in.
|
||||||
* @param $line
|
* @param $line
|
||||||
* The line number the error was raised at.
|
* The line number the error was raised at.
|
||||||
* @param $context
|
|
||||||
* An array that points to the active symbol table at the point the error
|
|
||||||
* occurred.
|
|
||||||
*/
|
*/
|
||||||
function _drupal_error_handler_real($error_level, $message, $filename, $line, $context) {
|
function _drupal_error_handler_real($error_level, $message, $filename, $line) {
|
||||||
if ($error_level & error_reporting()) {
|
if ($error_level & error_reporting()) {
|
||||||
$types = drupal_error_levels();
|
$types = drupal_error_levels();
|
||||||
list($severity_msg, $severity_level) = $types[$error_level];
|
list($severity_msg, $severity_level) = $types[$error_level];
|
||||||
|
|
|
@ -67,14 +67,14 @@ class QueryTest extends DatabaseTestBase {
|
||||||
public function testConditionOperatorArgumentsSQLInjection() {
|
public function testConditionOperatorArgumentsSQLInjection() {
|
||||||
$injection = "IS NOT NULL) ;INSERT INTO {test} (name) VALUES ('test12345678'); -- ";
|
$injection = "IS NOT NULL) ;INSERT INTO {test} (name) VALUES ('test12345678'); -- ";
|
||||||
|
|
||||||
$previous_error_handler = set_error_handler(function ($severity, $message, $filename, $lineno, $context) use (&$previous_error_handler) {
|
$previous_error_handler = set_error_handler(function ($severity, $message, $filename, $lineno) use (&$previous_error_handler) {
|
||||||
// Normalize the filename to use UNIX directory separators.
|
// Normalize the filename to use UNIX directory separators.
|
||||||
if (preg_match('@core/lib/Drupal/Core/Database/Query/Condition.php$@', str_replace(DIRECTORY_SEPARATOR, '/', $filename))) {
|
if (preg_match('@core/lib/Drupal/Core/Database/Query/Condition.php$@', str_replace(DIRECTORY_SEPARATOR, '/', $filename))) {
|
||||||
// Convert errors to exceptions for testing purposes below.
|
// Convert errors to exceptions for testing purposes below.
|
||||||
throw new \ErrorException($message, 0, $severity, $filename, $lineno);
|
throw new \ErrorException($message, 0, $severity, $filename, $lineno);
|
||||||
}
|
}
|
||||||
if ($previous_error_handler) {
|
if ($previous_error_handler) {
|
||||||
return $previous_error_handler($severity, $message, $filename, $lineno, $context);
|
return $previous_error_handler($severity, $message, $filename, $lineno);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -103,13 +103,13 @@ class LibraryDiscoveryTest extends UnitTestCase {
|
||||||
* Tests getting a deprecated library.
|
* Tests getting a deprecated library.
|
||||||
*/
|
*/
|
||||||
public function testAssetLibraryDeprecation() {
|
public function testAssetLibraryDeprecation() {
|
||||||
$previous_error_handler = set_error_handler(function ($severity, $message, $file, $line, $context) use (&$previous_error_handler) {
|
$previous_error_handler = set_error_handler(function ($severity, $message, $file, $line) use (&$previous_error_handler) {
|
||||||
// Convert deprecation error into a catchable exception.
|
// Convert deprecation error into a catchable exception.
|
||||||
if ($severity === E_USER_DEPRECATED) {
|
if ($severity === E_USER_DEPRECATED) {
|
||||||
throw new \ErrorException($message, 0, $severity, $file, $line);
|
throw new \ErrorException($message, 0, $severity, $file, $line);
|
||||||
}
|
}
|
||||||
if ($previous_error_handler) {
|
if ($previous_error_handler) {
|
||||||
return $previous_error_handler($severity, $message, $file, $line, $context);
|
return $previous_error_handler($severity, $message, $file, $line);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue