Bug #54071
closedcache.lifetime value returned as a string - error in Redis cache backend
0%
Description
I was experimenting with Redis as a cache backend for typo3 4.7. Everything seemed to be working ok until I enabled cache_hash using the following:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_hash']['backend'] = 't3lib_cache_backend_RedisBackend';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_hash']['options'] = array(
'hostname' => '127.0.0.1',
'database' => 13,
);
Typo3 started to generate the following exception:
Oops, an error occurred! The specified lifetime is of type "string" but a string or NULL is expected.
I've checked the source code of class.t3lib_cache_backend_redisbackend.php and lifetime is being checked for integer rather than a string:
[line 347] $lifetimeIsNull = is_null($lifetime);
[line 348] $lifetimeIsInteger = is_integer($lifetime);
[line 349]
[line 350] if (!$lifetimeIsNull && !$lifetimeIsInteger) {
So the value was failing the integer check. I've nailed the problem to a specific TyposScript object:
lib.forumNews = TEXT
lib.forumNews {
cache.key = bb7_forumnews
cache.lifetime = 60
cObject = COA
cObject {
10 = TEXT
10.value = <h5>...
20 = USER
20.userFunc = user_feeds->user_linki
30 = TEXT
30.value = <div class...
}
}
cache.lifetime is indeed being passed to redis cache script as a string of value "60". I've tried intval($lifetime) and it started to work smoothly.
I'm not sure what is the real error here - it's eithertyposcript bug and cache.lifetime should be returned as integer (makes sense) or redis cache backend should use intval when using the lifetime value.