Description
Symfony version(s) affected
5.4 (probably 4.4 also)
Description
Our application at some moment was connected to the Redis replica server (accidentally) for the cache.
When we are tried to delete the cache key - Redis throws an exception RedisException
- READONLY You can't write against a read-only replica.
(which is pretty OK - symfony/cache
should catch this error and suppress).
But application written many PHP warnings to the logs - PHP message: PHP Warning: Undefined property: Symfony\Component\Cache\Adapter\RedisTagAwareAdapter::$namespace in /.../vendor/symfony/cache/Adapter/RedisTagAwareAdapter.php on line 168
How to reproduce
- Connect to Redis replica server
- Use
\Symfony\Component\Cache\Adapter\RedisTagAwareAdapter::deleteItems()
Possible Solution
Sorry, symfony/cache
is pretty complex to me (heavy usage of traits, multi-level class hierarchy, universal redis adapters for all known drivers), so I can't suggest a fix (or at least an accurate test case).
Need to try to avoid using private trait property \Symfony\Component\Cache\Traits\AbstractAdapterTrait::$namespace
from \Symfony\Component\Cache\Adapter\RedisTagAwareAdapter
, or find a way to make this property accessible in this context.
Additional Context
PhpStorm mentions issue about inappropriate using trait private property in 2 places (linked from 4.4 branch):