-
-
Notifications
You must be signed in to change notification settings - Fork 451
Description
What type of issue is this?
Exception/Error/Warning/Notice/Deprecation
Operating system + version
Ubuntu 18.04
PHP version
8.4
Connector/Database version (if applicable)
No response
Phpfastcache version
9.2.0 ✅
Describe the issue you're facing
When using the File-based cache driver, the stored serialized data sometimes cannot be unserialized correctly.
The library throws an exception or marks the item as corrupted.
Exception
Failed to unserialize data from the cache, expected array or null but got boolean. Stored data may be corrupted.
Example error message (from logs or exception):
Unserialization failed or corrupted cache data in DriverBaseTrait::decode()
Observed Data Example
Below is a snippet of the actual data stored on disk (partial for readability):
a:6:{s:1:"k";s:12:"_TAG_product";s:1:"d";a:2017:{ s:32:"2438b973e0ba067e4341375c297f74a5";i:1760423285; s:32:"c8f7674da723c0d59f36a0a872033e69";i:1760423152; s:32:"7681cd0e7ae992ae98c32c041a0f142e";i:1760423152; s:32:"686bd7d70b1a645d835d17a03999006d";i:1760423152; s:32:"416390488ea388ebefe0b451f315a9dc";i:1760423297; s:32:"4e0bf26a8d7aa805ac4bc1d18756cdf8";i:1760423297; s:32:"6ca343c299810b91acf27384b678b427";i:1760423297; s:32:"c49bb7ba489a789a826714341c5e44a9";
Expected behavior
decode() should be able to safely and fully unserialize all data that was previously serialized by phpFastCache, or gracefully handle partial/corrupted files without failing the entire pool.
Code sample (optional)
No response
Suggestion to fix the issue (optional)
No response
References (optional)
No response
Do you have anything more you want to share? (optional)
- The corruption typically happens with large datasets (thousands of array entries).
- The data is written fully (no truncated file size), but unserialization fails. It might also possible that serialization is going to failed.
- Possibly related to file locking or concurrent writes during cache tag updates (TAG* files).
Have you searched in our Wiki before posting ?
- I have searched over the Wiki