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

Warning: substr() expects parameter 1 to be string, object given in Cache/Backend/Redis.php on line 1218 #151

Open
ilnytskyi opened this issue Feb 28, 2020 · 0 comments

Comments

@ilnytskyi
Copy link
Contributor

ilnytskyi commented Feb 28, 2020

Sometimes we randomly get errors like this

Warning: substr() expects parameter 1 to be string, object given in /var/www/html/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php on line 1218

the part of call stack:

Exception: Warning: substr() expects parameter 1 to be string, object given in /var/www/html/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php on line 1218 in /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'substr() expect...', '/var/www/prod.s...', 1218, Array)
#1 /var/www/html/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php(1218): substr(Object(Credis_Client), 2, 3)
#2 /var/www/html/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php(467): Cm_Cache_Backend_Redis->_decodeData(Object(Credis_Client))
#3 /var/www/html/vendor/magento/zendframework1/library/Zend/Cache/Core.php(306): Cm_Cache_Backend_Redis->load('b59_TRANSLATE_P...', false)
#4 /var/www/html/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(55): Zend_Cache_Core->load('b59_TRANSLATE_P...')

We noticed this line Cm_Cache_Backend_Redis->_decodeData(Object(Credis_Client))

The question:
In this method \Cm_Cache_Backend_Redis::load
The construction $this->_redis->hGet(self::PREFIX_KEY.$id, self::FIELD_DATA);
can return something else than bool|string ?

In signature we see this
Selection_415

maybe it's better to change if expression like this?

        if ($data === NULL || is_object($data)) {
            return FALSE;
        }

the app may not expect to get an object

Selection_416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant