kirby-dreamform
kirby-dreamform copied to clipboard
Exception: Serialization of 'Closure' is not allowed
When submitting a form with errors (e.g., required fields left empty), I receive the error message: Serialization of 'Closure' is not allowed. This occurs on my local machine and persists even when all non-essential plugins are disabled. I tried to provide as much information as possible, hopefully enough.
SubmissionSession.php:43
{
if (A::has(['prg', 'htmx'], DreamForm::option('mode', 'prg')) && !Htmx::isHtmxRequest()) {
return $this->storeSession();
}
if (!$this->exists()) {
App::instance()->cache('tobimori.dreamform.sessionless')->set($this->slug(), serialize($this), 60 * 24);
}
return static::$session = $this;
}
Strack trace
tobimori\DreamForm\Models\SubmissionPage::storeSessionlessCache
tobimori\DreamForm\Models\SubmissionPage::storeSession
tobimori\DreamForm\Models\FormPage::submit
tobimori\DreamForm\Models\FormPage::render
Kirby\Cms\App::io
Kirby\Cms\App::render
Dreamform config
'tobimori.dreamform' => [
'secret' => fn () => env('DREAMFORM_SECRET'),
'mode' => 'htmx',
],
Kirby info
{
"info": {
"kirby": "4.6.1",
"php": "8.3.17",
"server": "Apache/2.4.62 (Debian)",
"license": "Niet geregistreerd",
"languages": []
},
"security": [
"De debug modus moet uitgeschakeld zijn in productie"
],
"plugins": [
{
"name": "artcore-society/arty-custom-blueprints",
"version": "?"
},
{
"name": "artcore-society/arty-custom-marks",
"version": "?"
},
{
"name": "artcore-society/arty-page-info-field",
"version": "?"
},
{
"name": "artcore-society/arty-role-blueprints",
"version": "?"
},
{
"name": "artcore-society/kirby-blade",
"version": "?"
},
{
"name": "artcore-society/kirby-log",
"version": "?"
},
{
"name": "beebmx/kirby-env",
"version": "4.2.1"
},
{
"name": "bnomei/recently-modified",
"version": "4.3.0"
},
{
"name": "bnomei/securityheaders",
"version": "5.0.4"
},
{
"name": "junohamburg/language-selector",
"version": "1.1.9"
},
{
"name": "lukaskleinschmidt/laravel-vite",
"version": "2.1.3"
},
{
"name": "nerdcel/kirby-impersonate",
"version": "0.0.1"
},
{
"name": "tobimori/dreamform",
"version": "1.4.1"
},
{
"name": "tobimori/seo",
"version": "1.1.2"
},
{
"name": "tobimori/thumbhash",
"version": "1.1.1"
}
]
}
We found the issue. It was a conflict with our own Blade plugin. This Blade plugin breaks Dreamform because Dreamform tries to serialize our custom template class, but this class cannot be serialized.
As far as we know, Kirby never serializes its templates, and there is no mention of this being required in the official documentation. Therefore, this issue only occurs when using Dreamform and the Blade plugin together in the same project.
What's the difference between your Blade plugin and https://github.com/lukasleitsch/kirby-blade ?
@tobimori I'm not the one who coded the package. But our developer had this to say:
Our custom template has PathService provided by dependency injection. PathService in turn has KirbyAdapter injected, which has an instance of Kirby\Cms\App injected. That Kirby App instance probably references our template again somewhere deep within. This causes dreamform's serialization to fail. We tested removing the dependency injection and replacing it with Kirby\Cms\App::instance() wherever Kirby was needed and this resolves the Dreamform bug.
this should be solved with the 2.0 update - we're now only storing the actual content and not the serialized class