Skip to content

Conversation

@alschastny
Copy link
Contributor

I discovered the following bug in parsing the XREAD response when null is returned. It can be easily reproduced with the following code:

$stream1Id1 = $redis->xadd('stream1', ['field1' => 'value1']);
$redis->xdel('stream1', $stream1Id1);
$redis->xread(1, null, ['stream1'], '0-0');

foreach() argument must be of type array|object, null given
 /predis/src/Command/Redis/XREAD.php:51
 /predis/src/Client.php:394
 /predis/src/Client.php:336
 /predis/tests/Predis/Command/Redis/XREAD_Test.php:180

To avoid changing the XREAD interface, I suggest returning an empty array.

@alschastny alschastny requested a review from tillkruss as a code owner June 16, 2025 12:54
@coveralls
Copy link

coveralls commented Jun 16, 2025

Coverage Status

coverage: 92.775% (+0.002%) from 92.773%
when pulling eb5ba8a on alschastny:xread-fix-read-null
into 9992595 on predis:main.

@alschastny alschastny force-pushed the xread-fix-read-null branch 2 times, most recently from ce9c288 to 9bf192f Compare June 16, 2025 13:03
@tillkruss tillkruss force-pushed the xread-fix-read-null branch from 9bf192f to eb5ba8a Compare June 16, 2025 16:44
@tillkruss tillkruss requested a review from vladvildanov June 16, 2025 16:48
@vladvildanov vladvildanov merged commit ec375af into predis:main Jun 17, 2025
25 checks passed
@tillkruss tillkruss mentioned this pull request Jun 17, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants