Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] PHP Warning in case of omited exception while trying to delete cache key for Redis adapter #45325

Closed
@andrew-demb

Description

@andrew-demb

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

  1. Connect to Redis replica server
  2. 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):

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions