[13.x] Prevent fatal errors when logging deprecations fails - #60893
Merged
Conversation
crynobone
approved these changes
Jul 27, 2026
shaedrich
reviewed
Jul 27, 2026
Comment on lines
+106
to
+114
| with($logger->channel('deprecations'), function ($log) use ($message, $file, $line, $level, $options) { | ||
| if ($options['trace'] ?? false) { | ||
| $log->warning((string) new ErrorException($message, 0, $level, $file, $line)); | ||
| } else { | ||
| $log->warning(sprintf('%s in %s on line %s', | ||
| $message, $file, $line | ||
| )); | ||
| } | ||
| }); |
Contributor
There was a problem hiding this comment.
You may shorten this to the following and reduce the cognitive load if you want:
Suggested change
| with($logger->channel('deprecations'), function ($log) use ($message, $file, $line, $level, $options) { | |
| if ($options['trace'] ?? false) { | |
| $log->warning((string) new ErrorException($message, 0, $level, $file, $line)); | |
| } else { | |
| $log->warning(sprintf('%s in %s on line %s', | |
| $message, $file, $line | |
| )); | |
| } | |
| }); | |
| with( | |
| $logger->channel('deprecations'), | |
| fn ($log) => $log->warning(($options['trace'] ?? false) | |
| ? (string) new ErrorException($message, 0, $level, $file, $line), | |
| : sprintf('%s in %s on line %s', $message, $file, $line), | |
| ), | |
| ); |
Collaborator
Author
There was a problem hiding this comment.
I think that's a worse refactor tbh. This is an abuse of expressions for something that should be a statement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The prefer-lowest builds on 13.x are currently failing because PHP 8.4 raises an implicit-nullable deprecation while compiling Monolog 3.4's Logger class. The deprecation handler then attempts to log through Monolog while that class is still mid-autoload, and the process fatals with a "Class Monolog\Logger not found" error. This is what kills the Concurrency child processes on Linux and the ExceptionHandler subprocess on Windows. Reporting a deprecation should never be able to crash the application, so the logging attempt now ignores any failure that occurs while building or using the deprecations channel.