Skip to content

Commit 93a8def

Browse files
mikebronnerclaude
andauthored
fix: serialize cache values to fix Cacheable with serializable_classes (#588) (#589)
* fix: 🐛 serialize cache values to fix Cacheable with serializable_classes When Laravel's `cache.serializable_classes` is set to `false` (or a restricted array), PHP's `unserialize()` converts stored Eloquent models into `__PHP_Incomplete_Class` objects, making cached results unusable. ModelCacheRepository now wraps every stored value with a sentinel prefix (`genealabs:lmc:v1:serialized:`) and explicit `serialize()`/`unserialize()` calls, bypassing the driver-level `allowed_classes` restriction entirely. The transparent `makeCacheDeserializeProxy` in test infrastructure auto-deserializes values so existing tests need no per-call changes. Closes #588 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: ✅ verify serializable_classes=true and dedupe deserialization helper Addresses tracer bullet review feedback on #589: - Added test_cacheable_trait_works_when_serializable_classes_is_true to exercise the Cacheable trait under the actual restriction the bug reports. Existing tests set the config to false before caching, which never proved the fix. Updated the "under restriction" test to set serializable_classes=true *before* the cached calls. - Extracted deserializeCacheValue helper on CreatesApplication so the prefix-detection logic lives in one place. DynamoDbModelCachingTest now calls the helper instead of duplicating the unserialize incantation. - Verified ModelCacheRepository has no remember(\$ttl) method — only get/rememberForever/forever/forget — so all write paths are already covered by the prefix wrapping in PR #589. * test: ✅ Brought all tests back to green. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b16d2a9 commit 93a8def

File tree

8 files changed

+11225
-24
lines changed

8 files changed

+11225
-24
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
.phpunit.result.cache
2828
npm-debug.log
2929
yarn-error.log
30+
/tests/database/parallel-*/
3031

3132
# -----------------
3233
# Homestead and Auth Configs
@@ -77,8 +78,6 @@ tmplaravel*
7778
_ide_helper*.php
7879
.cursorrules
7980
/vendor/laravel-ide/*
80-
/tests/database/*.sqlite-journal
81-
composer.lock
8281

8382
# ignore all the ai configuration files, have laravel boost manage them and the developer choose their setup
8483
.ai

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"laravel/pint": "^1.27",
4141
"mikebronner/development-settings": "^0.1.15",
4242
"orchestra/testbench": "^9.0|^10.0|^11.0",
43-
"pestphp/pest": "^3.0",
44-
"pestphp/pest-plugin-laravel": "^3.0",
43+
"pestphp/pest": "^3.0|^4.0",
44+
"pestphp/pest-plugin-laravel": "^3.0|^4.0",
4545
"phpunit/phpunit": "^10.5|^11.5|^12.5",
4646
"slevomat/coding-standard": "^7.0|^8.14",
4747
"squizlabs/php_codesniffer": "^3.6|^4.0",

0 commit comments

Comments
 (0)