phpfastcache: Argument 1 passed to phpFastCache\Core\DriverAbstract::driverUnwrapTime() must be of the type array, boolean given

This just rarely happens but it is still a bug

Argument 1 passed to phpFastCache\Core\DriverAbstract::driverUnwrapTime() must be of the type array, boolean given, called in /somepath/ow_libraries/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Driver.php on line 122
File: /somepath/ow_libraries/vendor/phpfastcache/phpfastcache/src/phpFastCache/Cache/DriverBaseTrait.php 


Trace:

#0 /somepath/ow_libraries/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Driver.php(122): phpFastCache\Core\DriverAbstract->driverUnwrapTime(false)
#1 /somepath/ow_libraries/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/StandardPsr6StructureTrait.php(55): phpFastCache\Drivers\Files\Driver->driverRead(Object(phpFastCache\Drivers\Files\Item))
#2 /somepath/ow_libraries/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/ExtendedCacheItemPoolTrait.php(62): phpFastCache\Core\DriverAbstract->getItem('_TAG_friends.co...')
#3 /somepath/ow_libraries/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/ExtendedCacheItemPoolTrait.php(122): phpFastCache\Core\DriverAbstract->getItemsByTag('friends.count')
#4 /somepath/ow_libraries/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/ExtendedCacheItemPoolTrait.php(144): phpFastCache\Core\DriverAbstract->deleteItemsByTag('friends.count')
#5 /somepath/ow_plugins/ext/classes/backend_phpfastcache.php(54): phpFastCache\Core\DriverAbstract->deleteItemsByTags(Array)
.........................................................

My guess :

in \phpfastcache\phpfastcache\src\phpFastCache\Drivers\Files\Driver.php

$object = $this->decode($content);

not always return array.

Can I make a fix like this : adding !is_array($object) ||

  if (!is_array($object) || $this->driverUnwrapTime($object)->getTimestamp() < time()) {
        @unlink($file_path);

        return null;
    }

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 20 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Ok got it, i will fix it asap 😃

I just applied phpfastcache for around 1 week, no problem on Windows 10 so far.

The problem happened on our Production, which is ubuntu 16.04, the cache location is /tmp. we are running nginx-fpm along with php command client for cron job.

Merci pour la reponse rapide et le superbe lib 😃