Skip to content

[access] refactor(object): SaveObject takes a services bundle and its three access guards - #7594

Merged
rubenvdlinde merged 2 commits into
mainfrom
cloud/k17-saveobject-ctor
Nov 9, 2026
Merged

rubenvdlinde merged 2 commits into
mainfrom
cloud/k17-saveobject-ctor

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Lane K17 (round 10c), SIG unit interfacing: the SaveObject constructor.

What changed

  • SaveObject::__construct goes from 30 parameters to 4. It now takes SaveObjectServices plus the three access guards, which stay direct constructor parameters: PropertyRbacHandler, PermissionHandlerInterface and FolderManagementHandler (assertFolderIsAccessible).
  • SaveObjectServices nests final bundles of at most 4 parameters each, all in lib/Service/Object/SaveObject/:
    • persistence: SaveObjectPersistence, which holds SaveObjectMappers (object, unified, schema, register), SaveObjectRecords (audit trail, trail settings, TMLO, activity stamper) and SaveObjectRuntime (cache, object sources, flow-run context, container)
    • handlers: SaveObjectHandlers, which holds SaveObjectPropertyHandlers (metadata, file, linked entity, computed field) and SaveObjectValueHandlers (translation handler, projection, status, field encryption)
    • platform: SaveObjectPlatform (session, URL generator, logger, event dispatcher)
    • tenancy: SaveObjectTenancy (organisation service, group manager, app config)
  • Each collaborator keeps its own typed private readonly property, assigned one by one in the constructor. Method bodies are untouched, and the tests that set a collaborator by reflection on a constructor-less instance still work.
  • Optional collaborators keep their = null defaults inside the bundles, so the DI autowiring resolves the same services (or the same null) as before. SaveObject is still autowired through the ContractBindings aliases, and no registrar change is needed.
  • The @SuppressWarnings(PHPMD.ExcessiveParameterList) on the constructor is removed because the warning no longer applies.
  • This PR has 11 classes (SaveObject plus 10 bundles), one over the 10-class guideline. The bundles are 30-line data holders and cannot be split from the constructor change.

Tests

  • The 31 places in 30 test files that build SaveObject by hand now build the bundles. I made this change mechanically and kept every argument's value.
  • Ran every tests/Unit file naming SaveObject: all OK. SaveObjectsTest has its 1 pre-existing skip.
  • Ran tests/Unit/Architecture, Contract, Kernel, Service/Rules, ControllerServicesWiringTest and ControllerSessionWiringTest: 2658 OK.
  • phpcs and phpstan are clean on the touched lib files.

Numbers (lane_measure K17, this branch alone)

  • Over 4 parameters: 469 → 429 LOC
  • Over 6 parameters: 151 → 111 LOC

AI-assisted: written by Claude Code (Claude) for lane K17.


Generated by Claude Code

…cess guards

The 30-parameter constructor becomes four: SaveObjectServices (nested
bundles of at most four: mappers, records, runtime, property handlers,
value handlers, platform, tenancy) plus PropertyRbacHandler,
PermissionHandlerInterface and FolderManagementHandler, which stay direct
constructor parameters. Every collaborator keeps its own typed private
property, assigned one by one, so behaviour and the tests that set a
collaborator by reflection are unchanged. Optional collaborators keep their
null defaults inside the bundles, so DI autowiring resolves the same
services as before.

Every test that builds SaveObject by hand now builds the bundles.

Assisted-by: ClaudeCode:claude-opus-5-5
@rubenvdlinde
rubenvdlinde changed the base branch from development to main November 9, 2026 06:53

Copy link
Copy Markdown
Contributor Author

The red Newman API Test Suite check does not come from this PR.

The PHPUnit step inside the Nextcloud container fails with 11 errors and 11 failures. None of them are in files this diff touches. The failing tests are:

  • FileVersioningHandlerGoldenTest: "Cannot declare interface OCA\Files_Versions\Versions\IVersionManager", because the container ships that class.
  • JobRunMapperNarrowGoldenTest
  • EndpointsControllerAnswersGoldenTest
  • ProcessingLogServiceGoldenTest
  • TextExtractionJobsGoldenTest
  • SchemaConfigValidatorsGoldenTest
  • SearchReferenceResolverGoldenTest
  • A18InterfaceBindingsTest

The same set fails on unrelated open PRs #7541, #7543, #7538, #7540 and #7575. Outside the container these tests pass on plain development. There is no fix yet, and it does not belong in this PR.

The tests this PR changes pass in the same run, including every test that builds SaveObject.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

The red quality / Frontend Check (test:l10n) check is not caused by this PR.

The gate reports 14 translation keys used in src/ that are missing from l10n/en.js. This PR changes only PHP files under lib/ and tests/, and touches no .vue/.js file or any l10n catalogue. The repository's CLAUDE.md records npm run test:l10n as red at HEAD for this reason (keys added by a development merge without en.js entries).

The fix is a separate en.js change following docs/l10n-workflow.md §6.15, which does not belong in this PR.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

quality / Frontend Check (test:l10n:parity) is red, but not because of this PR.

Most locales are missing two keys that en.js already has: "Some objects could not be copied." and "We could not count the objects. Close this window and try again." This PR changes only .php files under lib/ and tests/. It touches no l10n catalogue and no frontend string, and the same gap exists on development.

No fix exists yet. The fix is translating those two keys in each locale (docs/l10n-workflow.md §6.15), and it belongs in its own per-locale commits.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

The red quality / PHP Quality (phpstan) and quality / Frontend Check (format) checks come from development, not from this PR.

No fix exists yet for either. Both belong outside this PR.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

The red quality / PHP Quality (phpcs) check is not caused by this PR.

phpcs reports 11 errors, all in files this PR does not change:

  • lib/Db/ImportPreviewRow.php
  • lib/Db/RuleRun.php
  • lib/Db/CaseItem.php
  • lib/Db/EntityRelation.php
  • lib/Db/MagicMapper/MagicObjectSearchInterface.php
  • lib/Service/Flow/FlowTokenRouter.php
  • lib/Service/Object/SaveObject/RelationCascadeHandler.php
  • lib/Service/ContractBindings.php

These errors are already on development. The files this PR touches (SaveObject and its ten new bundle classes) are not among them, and they pass phpcs locally.

No fix exists yet, and those files belong to other lanes, so the fix is outside this PR.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

The red quality / Vue Quality (eslint) check is not caused by this PR.

eslint reports 769 problems (16 errors, 753 warnings) in src/ frontend files and one JSON test fixture. These are the same findings as on #7575, and they are already on development. This PR changes only .php files under lib/ and tests/, which eslint does not lint.

No fix exists yet. It needs an eslint cleanup in its own PR.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

quality / PHP Quality (psalm) is red, but not because of this PR.

Psalm reports 60 errors across 35 files under lib/. This PR changes none of those files. Examples:

  • LessSpecificImplementedReturnType on the *LinkMapperInterface::findByObjectUuid family through FindLinksByObjectUuidTrait, and on EndpointMapper, WebhookMapper and Register::jsonSerialize
  • NullableReturnStatement in CredentialController and AuditTrail
  • InvalidPropertyAssignmentValue in MagicMapper/FacetResults
  • UnusedClosureParam in AppHost/ObservabilityWiring

These errors are already on development, and none touch SaveObject or its ten new bundle classes.

No fix exists yet. These files belong to other lanes, so the fixes do not belong in this PR.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

The red quality / Hydra Gates check is not caused by this PR.

Seven whole-tree gates fail, with the same counts as on the unrelated open PR #7541 and on #7540 and #7575:

  • gate-3: 1
  • gate-7: 113
  • gate-12: 1
  • gate-17: 1
  • gate-40: 1
  • gate-46: 2
  • gate-49: 19

The diff-scoped gates pass.

This PR changes no controller, so gates 7, 17 and 49 cannot have picked up anything from it. Gates 12 and 40 check Vue files, which this PR does not touch. The new bundle classes carry only the @spec path SaveObject already uses, and gate 46 still counts the same 2 findings.

No fix exists yet. These are gate debts already on development and belong outside this PR.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

quality / PHP Quality (phpmd) is red. Most findings are already on development, but four come from this PR.

The check fails with about 620 findings, and about 616 of them are already on development. The same check is red on #7540 and #7575.

This PR adds four new findings that are not on development:

  • lib/Service/Object/SaveObject.php:186 TooManyFields. The constructor's promoted properties became 27 explicitly declared typed properties, assigned from the bundles one by one. PHPMD counts declared fields but not promoted ones. The properties were kept so that the existing tests which set collaborators by reflection keep working.
  • lib/Service/Object/SaveObject/SaveObjectValueHandlers.php:48-50 LongVariable, three times: $translationProjectionService, $translationStatusService and $fieldEncryptionHandler. These are SaveObject's original parameter names. SaveObject suppresses LongVariable at class level; the new bundle does not.

These four do not decide the check, because it stays red without them. They should still be removed. I have not pushed to this PR, because under the lane rules an open PR is finished. The follow-up I propose:

  1. Shorten the three bundle parameters to projection, status and encryption. This needs no new suppression.
  2. For TooManyFields, have SaveObject keep the seven leaf bundles as properties instead of 27 fields, and move the reflection-setting tests to the bundle properties. This is a larger test change.

The coordinator can decide whether that lands here or as a follow-up PR after this one merges.


Generated by Claude Code

@rubenvdlinde
rubenvdlinde merged commit afc9050 into main Nov 9, 2026
37 of 49 checks passed
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 5e0a06c

Check PHP Vue Security License Tests
lint ✅
phpcs ❌
phpmd ❌
psalm ❌
phpstan ❌
phpmetrics ✅
eslint ❌
stylelint ✅
build ✅
check-specs ✅
test-l10n ❌
test-l10n-parity ❌
format ❌
check-schema-l10n ✅
test-coverage-ratchet ✅
composer ✅ ✅ 168/168
npm ✅ ✅ 641/641
app:check-code ⏭️
info.xml ✅
REUSE ✅
lockfile sync ✅
PHPUnit ❌ cancelled — no verdict
Newman ❌ 1625/1628
Playwright ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it locally with npx playwright test, or from the Actions tab on a branch with no open pull request into development.
Hydra gates ❌

Quality workflow — 2026-11-09 19:03 UTC

Download the full PDF report from the workflow artifacts.

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