snc/SncRedisBundle

RedisCluster::__construct() expects parameter 6 to be string, null given

Webonaute opened this issue · 2 comments

I started to get this error.

and client is php-redis extension 5.1.1
server has no password.

Any idea what can cause this?

[stderr]20:15:41 CRITICAL [console] Error thrown while running command "sonata:admin:setup-acl". Message: "RedisCluster::__construct() expects parameter 6 to be string, null given" ["exception" => TypeError { …},"command" => "sonata:admin:setup-acl","message" => "RedisCluster::__construct() expects parameter 6 to be string, null given"] ["memory_usage" => "63 MB","uid" => "62c7ff6cba3ebe75e20bbd8e35343e7d","version" => "master-f6ed00c-20220311201348-15092","request_id" => null,"env" => "beta"]
[stderr]
[stderr]In PhpredisClientFactory.php line 105:
[stderr]
[stderr] RedisCluster::__construct() expects parameter 6 to be string, null given

our config look like this :

snc_redis:
  clients:
    default:
      logging: false
      type: phpredis
      alias: default
      dsn:
        - '%cache_host%?alias=master'
      options:
        prefix: 'a-%api_build%_'
        cluster: true
    sessionClient:
      logging: false
      type: phpredis
      alias: sessionClient
      dsn:
        - '%cache_host%?alias=master'
      options:
        prefix: 'sess_'
        cluster: true
    noPrefixClient:
      logging: false
      type: phpredis
      alias: noPrefixClient
      dsn:
        - '%cache_host%?alias=master'
      options:
        cluster: true

More info:

seem that's coming from this change in redis cluster.

redis_cluster.c, 5.1.1:

    if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
                                    "Os!|addbs", &object, redis_cluster_ce, &name,
                                    &name_len, &z_seeds, &timeout, &read_timeout,
                                    &persistent, &auth, &auth_len) == FAILURE)

redis_cluster.c, 5.3.3:

    if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
                                    "Os!|addbza!", &object, redis_cluster_ce, &name,
                                    &name_len, &z_seeds, &timeout, &read_timeout,
                                    &persistent, &z_auth, &context) == FAILURE)

This 5.3.3 is not available on ubuntu right now so its impossible for me to use it.

so the declare(strict_types=1); on vendor/snc/redis-bundle/src/Factory/PhpredisClientFactory.php cause the error on the 5.1.1 version of phpredis.

This bundle doesn't support < 5.3 and is specifically forbidden by

"ext-redis": "<5.3",
. This is for a good reason. Stop using composer in --ignore-platform-reqs mode... If you need < 5.3, you will need to downgrade to 3.x version of this bundle.