Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HttpKernel] Fix logging deprecations to the "php" channel when channel "deprecation" is not defined #52707

Merged
merged 1 commit into from Nov 23, 2023

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #52672
License MIT

@stof
Copy link
Member

stof commented Nov 23, 2023

This will not log deprecations at all when not using MonologBundle and also won't log them at all when using MonologBundle without explicitly creating a deprecation channel.

This re-introduces the same issue than what was fixed previously. The "bug" you tried to fix is that someone was relying on the previous regression as a feature rather than a bug.

So -1 for me.

@nicolas-grekas
Copy link
Member Author

To me this will log deprecations on the php channel, as wanted

@nicolas-grekas
Copy link
Member Author

I think you missed that deprecations will go on the logger defined as $logger argument when $deprecationLogger is null.

@stof
Copy link
Member

stof commented Nov 23, 2023

If this is indeed the case, why did we have to replace the usage of service('monolog.logger.deprecation')->nullOnInvalid() by a dynamic configuration in the compiler pass in the previous PR ?

@nicolas-grekas
Copy link
Member Author

We did that to wire "logger" by default so that when monolog is not there, we still have a logger for the php notices/deprecations.

@stof
Copy link
Member

stof commented Nov 23, 2023

but you now wire null by default, not logger.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Nov 23, 2023

Sure, that's the code in DebugHandlersListener that does the trick:

$defaultLoggerLevels = $this->levels;
if ($this->deprecationLogger && $levelsDeprecatedOnly) {
$handler->setDefaultLogger($this->deprecationLogger, $levelsDeprecatedOnly);
$defaultLoggerLevels = $levelsWithoutDeprecated;
}
if ($this->logger && $defaultLoggerLevels) {
$handler->setDefaultLogger($this->logger, $defaultLoggerLevels);
}

@nicolas-grekas nicolas-grekas merged commit 32f22e0 into symfony:5.4 Nov 23, 2023
3 of 11 checks passed
@nicolas-grekas nicolas-grekas deleted the hk-fix-log-php branch November 23, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants