Commit e9969b0f authored by catch's avatar catch
Browse files

Issue #3173888 by andypost, alexpott, Gábor Hojtsy: Error handler signature changed in PHP 8

parent a5665ea2
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -299,13 +299,10 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
 *   (optional) The filename that the error was raised in.
 * @param $line
 *   (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';
  _drupal_error_handler_real($error_level, $message, $filename, $line, $context);
  _drupal_error_handler_real($error_level, $message, $filename, $line);
}

/**
+1 −4
Original line number Diff line number Diff line
@@ -54,11 +54,8 @@ function drupal_error_levels() {
 *   The filename that the error was raised in.
 * @param $line
 *   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()) {
    $types = drupal_error_levels();
    list($severity_msg, $severity_level) = $types[$error_level];
+2 −2
Original line number Diff line number Diff line
@@ -67,14 +67,14 @@ public function testArrayArgumentsSQLInjection() {
  public function testConditionOperatorArgumentsSQLInjection() {
    $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.
      if (preg_match('@core/lib/Drupal/Core/Database/Query/Condition.php$@', str_replace(DIRECTORY_SEPARATOR, '/', $filename))) {
        // Convert errors to exceptions for testing purposes below.
        throw new \ErrorException($message, 0, $severity, $filename, $lineno);
      }
      if ($previous_error_handler) {
        return $previous_error_handler($severity, $message, $filename, $lineno, $context);
        return $previous_error_handler($severity, $message, $filename, $lineno);
      }
    });
    try {
+2 −2
Original line number Diff line number Diff line
@@ -103,13 +103,13 @@ public function testGetLibraryByName() {
   * Tests getting a deprecated library.
   */
  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.
      if ($severity === E_USER_DEPRECATED) {
        throw new \ErrorException($message, 0, $severity, $file, $line);
      }
      if ($previous_error_handler) {
        return $previous_error_handler($severity, $message, $file, $line, $context);
        return $previous_error_handler($severity, $message, $file, $line);
      }
    });