mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge pull request #6711 from marc1706/ticket/17384-master
[ticket/17384] Stop overriding error handler in test case and ignore E_DEPRECATED for expecting errors
This commit is contained in:
commit
5681ceb73a
2 changed files with 2 additions and 31 deletions
|
@ -31,8 +31,6 @@ class phpbb_test_case extends TestCase
|
||||||
|
|
||||||
'phpbb_database_test_case' => ['already_connected', 'last_post_timestamp'],
|
'phpbb_database_test_case' => ['already_connected', 'last_post_timestamp'],
|
||||||
];
|
];
|
||||||
|
|
||||||
set_error_handler([$this, 'trigger_error_callback']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_test_case_helpers()
|
public function get_test_case_helpers()
|
||||||
|
@ -49,31 +47,4 @@ class phpbb_test_case extends TestCase
|
||||||
{
|
{
|
||||||
$this->get_test_case_helpers()->setExpectedTriggerError($errno, $message);
|
$this->get_test_case_helpers()->setExpectedTriggerError($errno, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Passing E_USER_ERROR to trigger_error() is deprecated as of PHP 8.4, so it causes E_DEPRECATED
|
|
||||||
* Use trigger_error() callback function to workaround this by handling E_USER_ERROR and suppressing E_DEPRECATED
|
|
||||||
* "Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead"
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function trigger_error_callback($errno, $errstr, $errfile, $errline)
|
|
||||||
{
|
|
||||||
// $errstr may need to be escaped
|
|
||||||
$errstr = htmlspecialchars($errstr);
|
|
||||||
|
|
||||||
switch ($errno) {
|
|
||||||
case E_USER_ERROR:
|
|
||||||
echo $errstr;
|
|
||||||
exit();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case E_DEPRECATED:
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ class phpbb_test_case_helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setExpectedTriggerError($errno, $message = '')
|
public function setExpectedTriggerError($errno, $message = ''): void
|
||||||
{
|
{
|
||||||
set_error_handler(
|
set_error_handler(
|
||||||
static function ($errno, $errstr)
|
static function ($errno, $errstr)
|
||||||
|
@ -112,7 +112,7 @@ class phpbb_test_case_helpers
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
throw new Exception($errstr, $errno);
|
throw new Exception($errstr, $errno);
|
||||||
},
|
},
|
||||||
E_ALL
|
E_ALL ^ E_DEPRECATED
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->expectedTriggerError = true;
|
$this->expectedTriggerError = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue