Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Correctly skip suppressed errors in PHP 8.0
Applies the suggested transformation mentioned in
https://www.php.net/manual/en/migration80.incompatible.php,

> The @ operator will no longer silence fatal errors (E_ERROR,
> E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR,
> E_PARSE). Error handlers that expect error_reporting to be 0 when
> @ is used, should be adjusted to use a mask check instead

The new code still works on PHP 7, as error_reporting() already
returns 0 when diagnostics are suppressed.

This fixes #25807 in PHP 8.0.
For PHP 7.x, #22243 suppresses
the E_NOTICE message from the second session_start() call with the error
suppression operator @, and thus those E_NOTICE messages are still
logged in PHP 8.0.

See also #25806

Signed-off-by: Chih-Hsuan Yen <[email protected]>
  • Loading branch information
yan12125 committed Jul 14, 2021
commit be51d8390b7c35a2914c745ccbacfddbbf3abf89
2 changes: 1 addition & 1 deletion lib/private/Log/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function onException($exception) {

//Recoverable errors handler
public static function onError($number, $message, $file, $line) {
if (error_reporting() === 0) {
if (!(error_reporting() & $number)) {
return;
}
$msg = $message . ' at ' . $file . '#' . $line;
Expand Down