Skip to content

Type error in Redis usage #34

Description

@MyIgel

Running

<?php

declare(strict_types=1);

$redis = new Redis();
$redis->connect('127.0.0.1', 6379, 0.1);
$redis->setOption(Redis::OPT_READ_TIMEOUT, 10);

leads to a TypeError error in PHP 7.3.10:

$ docker run -it --rm alpine:latest
/ # apk add php7 php7-redis
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/12) Installing php7-common (7.3.11-r0)
(2/12) Installing argon2-libs (20171227-r2)
(3/12) Installing ncurses-terminfo-base (6.1_p20190518-r0)
(4/12) Installing ncurses-terminfo (6.1_p20190518-r0)
(5/12) Installing ncurses-libs (6.1_p20190518-r0)
(6/12) Installing libedit (20190324.3.1-r0)
(7/12) Installing pcre2 (10.33-r0)
(8/12) Installing libxml2 (2.9.9-r2)
(9/12) Installing php7 (7.3.11-r0)
(10/12) Installing php7-pecl-igbinary (3.0.1-r1)
(11/12) Installing php7-session (7.3.11-r0)
(12/12) Installing php7-pecl-redis (4.3.0-r2)
Executing busybox-1.30.1-r2.trigger
OK: 20 MiB in 26 packages
/ # echo '[...]' > redistest.php
/ # php redistest.php; echo $?
PHP Fatal error:  Uncaught TypeError: Redis::setOption() expects parameter 2 to be string, int given in /redistest.php:7
Stack trace:
#0 /redistest.php(7): Redis->setOption(3, 10)
#1 {main}
  thrown in /redistest.php on line 7
255

Using a alpine:latest container with the php7 php7-redis packages (PHP 7.3.10 (cli) (built: Oct 3 2019 11:21:47) ( NTS ))

To me that looks more like it could be a bug in the redis package but sadly i have no deep enough knowledge to investigate that further.
It got fixed in phpredis >=5 but that makes this plugin incompatible to phpredis 4 which is currently distributed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions