Repository navigation
[access] refactor(access-purpose): share the read of recording and checking an access purpose - #5896
Merged
Merged
Conversation
…before they share the read Assisted-by: ClaudeCode:claude-opus-5-5
… access purpose record() and check() repeated the same read: the object service, the audit mapper, the register and both schemas (refused as not recorded when any is missing), the case (404 when it cannot be opened) and its special data categories. Both now call one private purposeRead(), split into purposeTarget() and readableCase(); the checks still run in the same order before anything is written. Assisted-by: ClaudeCode:claude-opus-5-5
rubenvdlinde
requested review from
WilcoLouwerse,
bbrands02 and
rjzondervan
as code owners
November 11, 2026 16:25
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.
What changed
CaseAccessPurposeService::record()andcheck()repeated the same read before writing anything: the object service, the audit mapper, the register and both schemas (refused as not recorded when any is missing), the case (refused with 404 when the reader cannot open it), and the special data categories of its type (indeterminate when the type cannot be read).Both now call one private
purposeRead(), which answers the mapper, the case and the categories; it is split intopurposeTarget()(the five settings reads and the one refusal) andreadableCase()so each unit stays small. The settings are read in the same order and refused the same way (no service or mapper, or an empty register or schema), the case is read through the samefind()(changed by #5340, not touched here), and everything after the read is unchanged, including each method's own answer for a case that asks no purpose.record()still checks the purpose before anything is read.The title carries the access prefix because this is the purpose binding around opening a case with special categories of personal data. Its allowed and refused outcomes are unchanged, as the tests below pin.
Characterisation tests
tests/Unit/Service/AccessPurposeReadGoldenTest.php, committed first and green on the old code: for both gestures, each of the five missing settings refuses as not recorded with nothing read; an unreadable case is refused with 404 after one read; an unreadable case type refuses as indeterminate; a case that asks no purpose answers each gesture's own shape. Nothing is written in any of them. 7 cases.CaseAccessPurposeServiceTest,AccessPurposeRulesGoldenTestandCaseAccessPurposeControllerTestpin the recorded purposes, the handler's open without a dialog and the skip purpose.Mutation check: letting an empty register or schema through in
purposeTarget()turned 2 cases red. Restored, all green.What ran
phpunit -c phpunit-unit.xmlon the four test classes above andtests/Unit/Architecture: 148 tests, all green but one inherited failure.phpcsandphpstan analyseon the touched file: no findings.Inherited:
ServiceCatchReturnsNullTest::testEveryAllowlistEntryNamesALiveSiteis red on development too (a stale allowlist entry forlib/Service/Settings/OpenRegisterBridge.php).Duplication figures
CaseAccessPurposeService: 26 -> 2 matching window pairs.AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.
Generated by Claude Code