Skip to content

Let it work with Laravel v12.53.0#35

Closed
waldemar-p wants to merge 5 commits into
aerni:mainfrom
waldemar-p:main
Closed

Let it work with Laravel v12.53.0#35
waldemar-p wants to merge 5 commits into
aerni:mainfrom
waldemar-p:main

Conversation

@waldemar-p

Copy link
Copy Markdown
Contributor

I think with Statamic 6.5 cam Laravel v12.53.0 and with that came a serializable_classes config.

If I am not mistaken that lead to some __PHP_Incomplete_Class errors upwards Statamic 6.5 ( I tried it from 6.8).

I tried to resolve that issue and also tried to lessen the memory footprint, because there are uses with a lot of font-awesome icons and that gets big quite fast. I know have a 53k lines json file as cache instead.

This version now worked for me but I am unsure if I went with the correct approach.

I also fixed a problem with the selected-option class property.

waldemar-p and others added 5 commits March 9, 2026 17:15
Update minimum requirements to PHP 8.2 and Statamic 6.0. Replace Laravel Mix with Vite for asset compilation. Include asset publishing instructions in README.
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().
@waldemar-p

Copy link
Copy Markdown
Contributor Author

I created an issue and a PR on statamic cms for the support of objects as modelValues inside the combobox.
statamic/cms#14451

@aerni

aerni commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Thanks for flagging these issues! I've addressed them in v4.0.1 across three separate PRs:

If I missed anything or you're still running into issues, feel free to open a new issue or PR.

@aerni aerni closed this Apr 9, 2026
@waldemar-p

Copy link
Copy Markdown
Contributor Author

I still get an error and I think it has to do with the cache handling.

[2026-04-10 09:45:39] local.ERROR: Symfony\Component\HttpFoundation\Response::setContent(): Argument #1 ($content) must be of type ?string, __PHP_Incomplete_Class given, called in /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 81 {"exception":"[object] (TypeError(code: 0): Symfony\\Component\\HttpFoundation\\Response::setContent(): Argument #1 ($content) must be of type ?string, __PHP_Incomplete_Class given, called in /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 81 at /home/user/projectpath/vendor/symfony/http-foundation/Response.php:426)
[stacktrace]
#0 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Http/Response.php(81): Symfony\\Component\\HttpFoundation\\Response->setContent(Object(__PHP_Incomplete_Class))
#1 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Http/Response.php(34): Illuminate\\Http\\Response->setContent(Object(__PHP_Incomplete_Class))
#2 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(939): Illuminate\\Http\\Response->__construct(Object(__PHP_Incomplete_Class), 200, Array)
#3 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(906): Illuminate\\Routing\\Router::toResponse(Object(Illuminate\\Http\\Request), Object(__PHP_Incomplete_Class))
#4 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(799): Illuminate\\Routing\\Router->prepareResponse(Object(Illuminate\\Http\\Request), Object(__PHP_Incomplete_Class))
#5 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(764): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#6 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(753): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#7 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#8 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#9 /home/user/projectpath/vendor/statamic/cms/src/Http/Middleware/StopImpersonating.php(13): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#10 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Statamic\\Http\\Middleware\\StopImpersonating->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#11 /home/user/projectpath/vendor/statamic/cms/src/Http/Middleware/CheckMultisite.php(15): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#12 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Statamic\\Http\\Middleware\\CheckMultisite->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#13 /home/user/projectpath/vendor/statamic/cms/src/Http/Middleware/CheckComposerJsonScripts.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#14 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Statamic\\Http\\Middleware\\CheckComposerJsonScripts->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#15 /home/user/projectpath/vendor/statamic/cms/src/Http/Middleware/PoweredByHeader.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Statamic\\Http\\Middleware\\PoweredByHeader->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(109): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(61): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Http\\Middleware\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Http\\Middleware\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#33 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#34 /home/user/projectpath/public/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#35 /home/user/projectpath/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(23): require_once('/home/wallek/Wo...')
#36 {main}
"}

But that is probably an error inside of statamic itself, right?

Even though with the code I provided, it worked because it has overwritten some ResponseCache methods.

@aerni

aerni commented Apr 10, 2026

Copy link
Copy Markdown
Owner

Yeah, not an issue of this addon. I didn't run into it myself. Maybe update Laravel and Statamic.

@waldemar-p

Copy link
Copy Markdown
Contributor Author

Thanks, you're right. That bug was resolved on statamic/cms 6.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants