Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if data is countable #1495

Open
wants to merge 1 commit into
base: v2.x
Choose a base branch
from

Conversation

streamingsystems
Copy link
Contributor

Hi,

Every once in a while we see this in our logs where Redis seems to be returning data that is not countable.

If I check if the data is_countable prior prior to the loop it fixes it.

[2024-12-05 15:23:03] worker.ERROR: count(): Argument #1 ($value) must be of type Countable|array, int given {"exception":"[object] (TypeError(code: 0): count(): Argument #1 ($value) must be of type Countable|array, int given at /home/ss/application/vendor/predis/predis/src/Command/Redis/ZRANGE.php:96)
[stacktrace]
#0 /home/ss/application/vendor/predis/predis/src/Command/Redis/ZRANGE.php(96): count(0)
#1 /home/ss/application/vendor/predis/predis/src/Client.php(391): Predis\Command\Redis\ZRANGE->parseResponse(0)

@tillkruss
Copy link
Member

@vladvildanov this seems like an issue with not detecting the mode in 6.2 doesn't it?

@streamingsystems What Redis version are you using?

@streamingsystems
Copy link
Contributor Author

Hi,

From regis-cli I run info:

Server

redis_version:7.2.4

The strange this is that we have many thousands of requests this go through our redis system and randomly will get that in the logs.

If it matters we are running sentinel and master / replica setup.

@streamingsystems
Copy link
Contributor Author

I saw this again again this morning:

[2024-12-06 07:53:04] worker.CRITICAL: count(): Argument #1 ($value) must be of type Countable|array, int given
[2024-12-06 07:53:04] worker.ERROR: count(): Argument #1 ($value) must be of type Countable|array, int given {"exception":"[object] (TypeError(code: 0): count(): Argument #1 ($value) must be of type Counta
ble|array, int given at /home/ss/application/vendor/predis/predis/src/Command/Redis/ZRANGE.php:96)
[stacktrace]
#0 /home/ss/application/vendor/predis/predis/src/Command/Redis/ZRANGE.php(96): count(0)

Also, instead of is_countable($data) you can just put if ($data) {}, around the for loop - anything to stop $data which is an integer from being passed into count().

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.

3 participants