Skip to content

[6.x] Only build common field option defaults once - #15772

Merged
duncanmcclean merged 2 commits into
6.xfrom
common-field-option-defaults
Nov 2, 2026
Merged

duncanmcclean merged 2 commits into
6.xfrom
common-field-option-defaults

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request improves the performance of building publish forms by only building the common field option defaults once per request.

Previously, Field::preProcessedConfig() called Field::commonFieldOptions() for every field, just to read the default values of the common field options (instructions position, visibility, etc). That builds a set of config fields, including ~30 translated strings, every time, even though the defaults never change.

On an entry with ~1,300 fields (including nested ones), this brought the time spent building the blueprint's publish array down from ~258ms to ~53ms.

Related: #13385

@duncanmcclean
duncanmcclean merged commit 8b6682a into 6.x Nov 2, 2026
64 checks passed
@duncanmcclean
duncanmcclean deleted the common-field-option-defaults branch November 2, 2026 17:25
joshdaugherty added a commit to UAMS-Web/aether-incomplete-entries that referenced this pull request Nov 10, 2026
Closes #40.

Pins the behavior that `statamic/cms` 6.40.0 changes on code this add-on
calls, so the bump in #24 is judged against tests that fail if that
behavior moves. No `src/` file changes.

## Approach

- **Permission checks (statamic/cms#15773).** A new
`IncompletePublishedEntriesPermissionTest.php` signs in users holding
roles made of single permissions and reads what the widget shows them:
`view` on one collection, `edit` without `view`, and `edit` with and
without `edit other authors`. Roles are saved to a role file of the
test's own, so no other process reads them.
- **Field option defaults (statamic/cms#15772).**
`EntryValidatorTest.php` validates four entries in one process against a
blueprint whose fields differ in `validate`, `if` and `unless`, and
expects each field judged on its own options. A second test runs
`select`, `checkboxes`, `link` and `assets` fields through the
validator, each reporting a missing required value and accepting a
present one. The assets row uses a disk of its own per run, removed
afterwards.
- **Cold Stache (statamic/cms#15771).**
`IncompletePublishedEntriesOffRequestTest.php` scans, clears the Stache,
scans again, and expects an identical result.

## Verification

- With the widget's `can('view', $entry)` replaced by `true`, the three
permission tests fail (3 failed, 8 assertions); restored, they pass.
- The cold-Stache test fails when the failing entry is deleted between
the two scans, and passes unmodified.
- The option and fieldtype tests discriminate through present and
missing values in the same test; no mutation of `src/` was run against
them, since the behavior they pin lives in Statamic.
- `composer ci`: 413 tests passed (1130 assertions), PHPStan clean, Pint
and Rector clean, parallel-safety check OK.

## Test plan

- [x] `composer ci` passes locally on the branch.
- [x] Remote checks pass on this pull request (33 check runs on the head
commit, none failed; the lowest-supported `statamic/cms` job included).
- [x] The tests also pass on the #24 branch: the three changed test
files, installed from its lock (`statamic/cms` v6.40.0), 60 passed.

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

1 participant