You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Forms 2: rendering any form loads every submission, and each submission keeps its own copy of the form's fields #16159
Since 6.44.0 (Forms 2), any page that renders a form tag loads the whole form-submissions Stache store. Once a form has been saved in the new form builder, building that store also takes almost three times the memory. Together these took a site with ~13k stored submissions from working to a fatal error on every page whenever the Stache is cold.
1. {{ form:create }} looks up a partial submission even when there isn't one
Statamic\Forms\Tags::getSectionsForTab() calls getPartialSubmission() for each section. That calls $this->form()->submission($id) even when the session holds no partial submission ($id === null). FormSubmission::find(null) still indexes the whole store, so on a cold Stache a page that only displays a form reads every submission file. This happens without Forms Pro, when the form can't have pages at all.
Possible fix: return null early when $id is null (or when ! $this->form()->hasMultiplePages()).
2. Every submission hydrates its own Form
FormSubmissionsStore::makeItemFromFile() calls Form::find($handle) once per submission file, and FormRepository::find() hydrates a new Form each time. Once a form is saved in the Forms 2 builder its fields are stored inline in the form YAML. From then on, every submission object carries its own parsed copy of the whole field list, so memory grows with submissions × form size.
Possible fix: resolve each form once per handle while building the store (e.g. via Blink).
Numbers
One form with 26 fields and ~12.8k stored submissions. Flat-file Stache, PHP 8.4. Peak memory of a single FormSubmission::find() on a cold Stache:
peak memory
6.39.0
196 MB
6.44.2, form not yet saved in the builder
196 MB
6.44.2, after saving the form in the builder
540 MB
The first request for a page containing the form, on a cold Stache, peaks at 85 MB on 6.39.0 and 575 MB on 6.44.2 (form saved in the builder). With memory_limit=512M the 6.44.2 request ends in Allowed memory size of 536870912 bytes exhausted on every page, until the Stache is warmed from the CLI with a higher limit.
How to reproduce
Create a form with ~25 fields and ~10k stored submissions.
Open the form in the new form builder and save it.
Run php please stache:clear.
With memory_limit=512M, load any page that contains {{ form:create in="your_form" }}.
Environment
Statamic 6.44.2, Laravel 12.75, PHP 8.4, flat-file (Stache) submissions, no Forms Pro.
Activity