Support a serializable classes value on caches#58911
Merged
Merged
Conversation
waldemar-p
added a commit
to waldemar-p/statamic-font-awesome
that referenced
this pull request
Apr 7, 2026
Laravel v12.53.0 (Feb 2026) introduced a serializable_classes config for cache stores (laravel/framework#58911) that restricts which PHP classes can be deserialized. When active, unserialize() rejects any class not on an explicit allowlist, turning it into __PHP_Incomplete_Class. Statamic v6.5.0 added Laravel 13 support, and upgrading Statamic also pulled in Laravel 12.53+ where this feature became available. The first manifestation of this issue appeared around Statamic v6.8.0: the addon stored Icons, Icon, Kit, and Collection objects via Cache::rememberForever(), which uses PHP serialize(). After the Laravel update, these classes were not on the serialization allowlist and became __PHP_Incomplete_Class upon retrieval. Statamic v6.10.0 (statamic/cms#14416) explicitly added Statamic's own classes to the allowlist, but third-party addon classes are not included. This made the error persistent rather than intermittent. Additionally, Statamic's GraphQL DefaultCache serializes the entire JsonResponse object via Cache::put(). Objects nested in the Response that are not on the allowlist also produce __PHP_Incomplete_Class, breaking GraphQL response caching entirely. On top of this, serializing the large icon collection (thousands of objects) caused memory exhaustion on sites with standard PHP memory limits. Changes: - Replace Cache::rememberForever() with JSON file caching for icons, kit data, and styles. Cache files are stored in storage/framework/cache/font-awesome/ as plain JSON — no PHP serialization involved. - Use streaming writes (fwrite per icon) for the icon cache to reduce peak memory usage when writing large icon collections. - Add a separate styles cache so styles() no longer loads the full icon collection — just a small JSON array of style names. - Serve cached icons JSON directly from disk via response()->file() in the controller, avoiding object instantiation entirely. - Add instance-level $cachedIcons property to prevent redundant file reads within a single request. - Introduce SafeResponseCache implementing Statamic's ResponseCache contract. Caches only the content string, status code, and headers array — all plain scalars — instead of the full Response object. Bound in ServiceProvider::boot() to override Statamic's DefaultCache which binds in register().
This was referenced Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.