Sitelet https://github.com/phpredis/phpredis/issues/2454
Skip to content

Redis scan cursor returns unsigned int, conversion to signed int causes incorrect cursor on following iteration. #2454

Description

@mikemoranmurj

Expected behaviour

When running a redis scan command, I expect the iterator to be the same value as the redis cursor.

Actual behaviour

The cursor is being converted to a signed int, while redis returns an unsigned int. So any cursor over the signed int max value is set to the signed int max value before the next scan iteration.

I'm seeing this behaviour on

-OS: Linux

  • Redis: 8.1
  • PHP: 8.2
  • phpredis: 6.0.2

Steps to reproduce, backtrace or example script

When redis scan command returns a cursor larger than the signed int max value,
$iter will be 9223372036854775807, which is sent to redis for the next iteration.

do {
  $arr_keys = $redis->scan($iter, $server, $pattern, $count);
      if($arr_keys !== FALSE){
          foreach($arr_keys as $str_key){
              echo "key";
          }
      }
  echo $iter;
}
while($iter > 0);

This is using RedisCluster with a targeted node in the scan parameters

I've checked

  • There is no similar issue from other users
  • Issue isn't fixed in develop branch

Activity

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

Metadata

Metadata

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