-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Cache] Error message does not contain cache-adapter
placeholder, so it will not populated
#48504
Comments
Maybe we could add the adapter to the message when trigger_error is used? if (isset($context['cache-adapter']) && !isset($replace['{cache-adapter}'])) {
$message .= sprintf(' (from "%s")', $context['cache-adapter']);
} or something like that? |
This might be an approach indeed.. But would changing the error message not be more pragmatic / simpler / less magic? Coming month quite busy... so will be 2023Q1 earliest |
I personally like compact messages :) |
Thank you for this suggestion. |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
@carsonbot sorry, did not have time yet to dive into this. Anyone else? |
Thank you for this suggestion. |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Hi @carsonbot, thanks for the reminder. No nothing has been done from my side due to lack of time. I still see think that injecting the name of the CacheAdapter in the error message would be useful for people that use a chain of multiple CacheAdapters. |
Symfony version(s) affected
6.2.0
Description
When a CacheAdapter logs an error using
CacheItem::log()
, an array with context information is provided. Often this array also include the'cache-adapter' => get_debug_type($this)
to handover the name of the cache adapter to the error message, which is useful when multiple CacheAdapters are involved.https://github.com/symfony/cache/blob/64cb231dfb25677097d18503d1ad4d016b19f19c/Adapter/AbstractAdapter.php#L182-L183
However, since the message itself does not contain the
cache-adapter
placeholder, this information is not included in the eventual error message.https://github.com/symfony/cache/blob/64cb231dfb25677097d18503d1ad4d016b19f19c/CacheItem.php#L155-L161
When a PSR Logger is assigned to the CacheAdapter, this might not be a big problem (since the context is handed over and used in another way). But when
trigger_error
is used, this information is really lost.How to reproduce
Have a CacheAdapter log a messages using CacheItem::log() and check whether the name of the CacheAdapter end up in the error message of the logs.
Possible Solution
Include
{cache-adapter}
placeholder in the error message, for example:Additional Context
No response
The text was updated successfully, but these errors were encountered: