colinmollenhour / Cm_Cache_Backend_Redis

A Zend_Cache backend for Redis with full support for tags (works great with Magento)
Other
390 stars 142 forks source link

Deprecated Functionality: strlen(): Passing null to parameter #1 ($string) of type string is deprecated #178

Closed vtiertant closed 10 months ago

vtiertant commented 10 months ago

Hello,

Since last update yesterday, we have an error on Magento 2 (Magento ver. 2.4.6-p1) after flushing cache :

Deprecated Functionality: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/magento/src/vendor/colinmollenhour/credis/Client.php on line 1618
There is an error in /var/www/html/magento/src/vendor/magento/framework/App/ErrorHandler.php at line: 62
Deprecated Functionality: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/magento/src/vendor/colinmollenhour/credis/Client.php on line 1618#0 /var/www/html/magento/src/vendor/colinmollenhour/credis/Client.php(1618): Magento\Framework\App\ErrorHandler->handler()

Stack Trace :

1 [internal function]: Credis_Client::_map()

2 /var/www/html/magento/src/vendor/colinmollenhour/credis/Client.php(1613): array_map()

3 /var/www/html/magento/src/vendor/colinmollenhour/credis/Client.php(1178): Credis_Client::_prepare_command()

4 /var/www/html/magento/src/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php(608): Credis_Client->__call()

5 /var/www/html/magento/src/vendor/magento/zend-cache/library/Zend/Cache/Core.php(390): Cm_Cache_Backend_Redis->save()

6 /var/www/html/magento/src/vendor/magento/framework/Cache/Core.php(74): Zend_Cache_Core->save()

7 /var/www/html/magento/src/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(63): Magento\Framework\Cache\Core->save()

8 /var/www/html/magento/src/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\Cache\Frontend\Adapter\Zend->save()

9 /var/www/html/magento/src/vendor/magento/framework/Cache/Frontend/Decorator/TagScope.php(52): Magento\Framework\Cache\Frontend\Decorator\Bare->save()

10 /var/www/html/magento/src/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\Cache\Frontend\Decorator\TagScope->save()

11 /var/www/html/magento/src/vendor/magento/framework/App/Cache.php(73): Magento\Framework\Cache\Frontend\Decorator\Bare->save()

12 /var/www/html/magento/src/vendor/magento/framework/App/Cache/Proxy.php(81): Magento\Framework\App\Cache->save()

13 /var/www/html/magento/src/vendor/magento/framework/App/ProductMetadata.php(87): Magento\Framework\App\Cache\Proxy->save()

14 /var/www/html/magento/src/vendor/magento/framework/Console/Cli.php(99): Magento\Framework\App\ProductMetadata->getVersion()

15 /var/www/html/magento/src/bin/magento(22): Magento\Framework\Console\Cli->__construct()

16 {main}

I think it's due to this code in magento :

$this->_cache->save(
      $this->serializer->serialize($data),
      $scopeCode . '::' . $this->_cacheId
);

public function save($data, $identifier, array $tags = [], $lifeTime = null);

So lifeTime is always null

min(null, 86400) = null

strlen(null) => error

So, i have to disable lua in my cache config on env.php to fix it

colinmollenhour commented 10 months ago

I will push a fix for the deprecation warning soon. Note, in production you probably want to disable deprecation warnings. Also, you are using standalone mode, if you install ext-redis you will get better performance.

colinmollenhour commented 10 months ago

This is fixed in https://github.com/colinmollenhour/credis/commit/457215677648940e91b526b379ede86e0f271ecc - please update the colinmollenhour/credis dependency to the latest version (1.16.0).

colinmollenhour commented 10 months ago

Oh, and thanks for the report!