Repository navigation
[access] refactor(files-widget): split FilesWidgetService listing, upload, delete and folder resolution into named steps - #1074
Closed
rubenvdlinde wants to merge 2 commits into
Closed
rubenvdlinde wants to merge 2 commits into
rubenvdlinde wants to merge 2 commits into
Conversation
… uploads and deletes before the split Assisted-by: ClaudeCode:claude-opus-5-5
…ete and folder resolution into named steps Assisted-by: ClaudeCode:claude-opus-5-5
rubenvdlinde
requested review from
WilcoLouwerse,
bbrands02 and
rjzondervan
as code owners
November 11, 2026 18: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
FilesWidgetServicereads as named steps instead of thirteen branchy methods:getContentsForPlacementresolves the folder, descends, checks it is readable and hands it tolistVisibleItems(isListed, thensortItems, whose comparator comes fromitemComparatorinstead of a branchy closure).resolveConfiguredFolder(public, unchanged signature) →configuredNode→resolveByFileId(firstFolder) /resolveByPath/homeWhenUnconfigured;extractFileId→positiveIntFromDigits;descendInto→nodeBelow.uploadFiles(public, unchanged) checks the placement flag, resolves the folder andwritableFolder, thenstoreUploads→storeUpload(screening) →writeUpload. Screening isrejectUpload→isGenuineUpload→ size cap →rejectUploadType.resolveAvailableName→sanitiseUploadName→firstFreeNumberedName→numberedName. The destination folder and its MIME filter travel as oneFilesWidgetUploadTarget.deleteFile(public, unchanged) checks the placement flag, resolves the folder, thenuserNodeById,assertDeletableWithinanddeleteNode; the containment walk isisDescendantOf→hasAncestorWithId→parentOf.matchesMimeFilterfor nodes,mimeMatchesFilterfor uploads) now sharemimeMatchesFilter/mimeMatchesPattern.Allowed and refused outcomes are unchanged, every check runs before the operation it guards and in the original order, and the exceptions and error codes are the same.
Characterisation tests
tests/Unit/Service/FilesWidgetAccessGoldenTest.phpwas committed first, against the old code, and passes before and after. It pinsfileId/folderPath/ home-folder resolution (everyfileIdshape, file-not-folder fallback, missing and unreadable folders, user-folder failure), every refused sub-path (traversal not even looked up, missing, not permitted, a file, unreadable) and the propagation of other lookup errors, the listing order for each sort and the MIME filter, paging and limit clamping, the upload refusals in order (placement flag before any lookup, read-only target) and every per-entry screening code with the collision-free names, and every delete outcome (flag before any lookup, missing id, lookup error, outside the root, unreadable parent, beyond the walk depth, not deletable, failing delete, direct and nested children, the root itself). The upload screening test registers its temp files as genuine uploads through a namespaced test seam foris_uploaded_file; every other path still goes to PHP. Mutation check: making the containment walk always succeed on the old code turned three delete goldens red; restored before committing.What ran
vendor/bin/phpunit -c phpunit.xml --no-coverage tests/Unit: 2795 tests OK (13 skipped, as on development).vendor/bin/phpcsandvendor/bin/phpstan analyseon the touched lib files: clean.Figures (touched files
lib/Service/FilesWidgetService.php,lib/Service/FilesWidgetUploadTarget.php)App-wide: unit complexity 4.02 → 4.17, unit size 3.40 → 3.44, unit interfacing 3.14 → 3.17, duplication 4.54 → 4.55.
Maintainability floor: compare against development holds.
AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.
Generated by Claude Code