Skip to content

[access] refactor(access-purpose): share the read of recording and checking an access purpose - #5896

Merged
rubenvdlinde merged 2 commits into
developmentfrom
quality/h16-purpose-read
Nov 12, 2026
Merged

rubenvdlinde merged 2 commits into
developmentfrom
quality/h16-purpose-read

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

What changed

CaseAccessPurposeService::record() and check() 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 into purposeTarget() (the five settings reads and the one refusal) and readableCase() 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 same find() (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.
  • The existing CaseAccessPurposeServiceTest, AccessPurposeRulesGoldenTest and CaseAccessPurposeControllerTest pin 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.xml on the four test classes above and tests/Unit/Architecture: 148 tests, all green but one inherited failure.
  • phpcs and phpstan analyse on the touched file: no findings.
  • The duplicated-fragment and unit ratchet (gate 122) against development: 0 findings.

Inherited: ServiceCatchReturnsNullTest::testEveryAllowlistEntryNamesALiveSite is red on development too (a stale allowlist entry for lib/Service/Settings/OpenRegisterBridge.php).

Duplication figures

  • inside 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

…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
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.

2 participants