Skip to content

[Cache] RedisTrait::createConnection() fails when only relay extension is present #62601

@kkrasnik

Description

@kkrasnik

Symfony version(s) affected

since 6.3.0

Description

RedisTrait::createConnection() fails when relay extension is enabled and redis extension is disabled and predis/predis package is not present.

How to reproduce

php-redis extension disabled.
predis/predis package not installed.
php-relay extension enabled.

// test.php
use Symfony\Component\Cache\Adapter\RedisAdapter;

$redisClient = RedisAdapter::createConnection('redis://redis-host:6379');

Result:

Symfony\Component\Cache\Exception\CacheException: Cannot find the "redis" extension nor the "predis/predis" package.

Possible Solution

Change Symfony\Component\Cache\Traits\RedisTrait.php line 101:

        if (!\extension_loaded('redis') && !class_exists(\Predis\Client::class)) {
            throw new CacheException('Cannot find the "redis" extension nor the "predis/predis" package.');
        }

to:

        if (!\extension_loaded('redis') && !\extension_loaded('relay') && !class_exists(\Predis\Client::class)) {
            throw new CacheException('Cannot find the "redis", "relay" extensions nor the "predis/predis" package.');
        }

Additional Context

No response

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