feat!: remove MediaUploadDelegate.uploadFile - #629
Open
jkmassel wants to merge 2 commits into
Open
Conversation
This was referenced Sep 5, 2026
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/629")Built from d8b85e2 |
jkmassel
force-pushed
the
feat/remove-upload-file-hook
branch
from
September 8, 2026 16:12
f5cbf24 to
1eb400b
Compare
`MediaUploader` replaces it. Returning a raw response split one upload's HTTP across two owners — the host performed the `POST`, the editor drove the `post-process` retries and orphan cleanup behind it — and the hook received no form fields, so an attachment it uploaded landed unattached to its post. Neither is fixable while the hook returns a raw response, which is what the replacement changes. What is left is a clean division: a delegate transforms bytes and GutenbergKit owns delivery and its retries; a `MediaUploader` owns delivery and its retries entirely. There is no longer an in-between where the host performs the upload but the editor retries it. `handlesFile` no longer gates the temp copy for two callers, only for `processFile` — and only when no uploader is set, since an uploader takes over delivery for every file. `MediaUploadResponse` drops to internal on both platforms: `uploadFile` was the only public API that named it. BREAKING CHANGE: hosts implementing `uploadFile` must conform to `MediaUploader` instead. Hosts that only implement `processFile` / `handlesFile` are unaffected.
jkmassel
force-pushed
the
feat/remove-upload-file-hook
branch
from
September 9, 2026 00:49
1eb400b to
6bcc210
Compare
…d docs Review follow-ups to 6bcc210. No behavior change. `handlesFile`'s new doc said it is "only consulted when no `MediaUploader` is set". It is always consulted (`MediaUploadServer.swift:143`, `.kt:374`), and it still gates `processFile` (`.swift:306`, `.kt:534`) — a declined file reaches the uploader unprocessed. The implementation comment 160 lines away and the `an uploader sees a file the delegate's metadata gate would have declined` test on both platforms already said so. Replaced with wording lifted from that comment. Removing `uploadFile` also left the docs a host actually reads still advertising it: - The `mediaUploadDelegate` property summaries — what Xcode Quick Help and IDE hover show — said "customizing media file processing and upload behavior" (iOS) and "(resize, transcode, custom upload)" (Android). Both now describe transformation and point at `mediaUploader` for the upload case. - `MediaUploadResponse.statusCode` claimed the status could come from "the host's upload service". `MediaUploader.upload` returns `Data`, so the host path supplies a literal 201. - `MediaUploadServer`'s parameter docs, the `UploadResult.uploaded` doc, and Android's "won't process or upload" comment, whose iOS twin already read "won't process". Two non-doc changes ride along: - `UploadError.noUploader`'s message named a role the delegate no longer has: "No upload delegate or internal media client configured" becomes "No media uploader or ...". It reaches the editor in a 500 body; nothing asserts on it. - iOS's `MockUploadDelegate` became a duplicate of `ProcessOnlyDelegate` once `uploadFile` went. Android already consolidated on `ProcessOnlyDelegate`; iOS now matches. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jkmassel
marked this pull request as ready for review
September 9, 2026 16:41
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.
Stacked on #628. Sixth of ten PRs splitting #621. Almost entirely deletions.
What?
Removes
uploadFilefromMediaUploadDelegateon both platforms.MediaUploader(#628) replaces it.Why?
Returning a raw response split one upload's HTTP across two owners — the host performed the
POST, the editor drove thepost-processretries and orphan cleanup behind it — and the hook received no form fields, so an attachment it uploaded landed unattached to its post. Neither is fixable while the hook returns a raw response.What is left is a clean division: a delegate transforms bytes and GutenbergKit owns delivery and its retries; a
MediaUploaderowns delivery and its retries entirely. There is no longer an in-between where the host performs the upload but the editor retries it.How?
handlesFileno longer gates the temp copy for two callers, only forprocessFile. With aMediaUploaderset it can't decline the upload itself — an uploader delivers every file, so there is no passthrough to fall to — but it still gatesprocessFile, so a declined file reaches the uploader unprocessed. Pinned byan uploader sees a file the delegate's metadata gate would have declinedon both platforms.MediaUploadResponsedrops to internal on both platforms:uploadFilewas the only public API that named it. This is load-bearing for migration safety — Swift requires an explicit return type, so a host's staleuploadFilecannot compile without naming the type. Leave itpublicand the same removal breaks hosts silently instead.A second commit corrects the docs the removal left stale: the
mediaUploadDelegateproperty summaries — what Xcode Quick Help and IDE hover show — still advertised "custom upload" on both platforms and pointed nowhere atMediaUploader, andUploadError.noUploader's message still named the delegate as an alternative to the internal client.Testing Instructions
Tests for the removed path are rewritten rather than deleted — the delegate now processes and the internal client delivers, which is what the remaining path does.
swift test— 974 tests in 57 suites, greenxcodebuild test -scheme GutenbergKit-Package -sdk iphonesimulator— 585 tests in 36 suites, green. Covers the UIKit-gated code the hostswift testcompiles as empty, includingEditorViewController.:Gutenberg:testDebugUnitTest— 672 tests, 0 failures:app:assembleDebug— Android demo buildsswift build --build-tests— zero warningsBreaking change
Hosts implementing
uploadFilemust conform toMediaUploaderinstead. Hosts that only implementprocessFile/handlesFileare unaffected. Migration needed in WordPress-iOS, WordPress-Android and Jetpack.The break is a hard compile error on both platforms, not a silent redirect — Android on
overrideof nothing, iOS onMediaUploadResponseno longer being visible.uploadFileshipped inv0.20.0-alpha.0and no stable tag.