Skip to content

[13.x] Prevent fatal errors when logging deprecations fails - #60893

Merged
taylorotwell merged 1 commit into
13.xfrom
fix-deprecations-during-monolog-autoload
Jul 27, 2026
Merged

[13.x] Prevent fatal errors when logging deprecations fails#60893
taylorotwell merged 1 commit into
13.xfrom
fix-deprecations-during-monolog-autoload

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Collaborator

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.

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
));
}
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
),
);

@GrahamCampbell GrahamCampbell Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a worse refactor tbh. This is an abuse of expressions for something that should be a statement.

@taylorotwell
taylorotwell merged commit 7aef174 into 13.x Jul 27, 2026
59 checks passed
@taylorotwell
taylorotwell deleted the fix-deprecations-during-monolog-autoload branch July 27, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants