Repository navigation
[6.x] Speed up permission checks - #15773
Merged
Merged
Conversation
This was referenced Nov 10, 2026
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>
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.
This pull request speeds up permission checks by caching the values of the flattened permissions.
Statamic's
Gate::aftercallback checks whether an ability is a Statamic permission before getting involved. To do that, it mapped every flattened permission (~475 of them) to its value on every single gate check.#12258 already caches the flattened permissions, so this PR caches their values in a lookup alongside them, via a new
Permissions::contains()method. The values come from the same cached, flattened permissions, so the result of every check is the same as before. It's just quicker to get to.On an entry where the publish form makes ~2,300 permission checks (mostly from Assets fields), this saved ~190ms.
Related: #12258
Related: #13385