Follow-ups from the #625 review: upload credential refresh, native file input, cleanups

未关闭
#843 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
ios, javascript
领域
mobile

调研方向

Start by reading AGENTS.md and tracing updateConfiguration(_:), prepareNativeHandlers(), InternalMediaClient, and the upload flow in api-fetch.js. Check how credentials and mixed selections reach uploads, then review the listed cleanup points in MediaUpload, RestRelaySchemeHandler, and EditorViewController. Done means the credential behavior and native file selection are correct and the documented cleanup and call-order issues are resolved.

由索引模型根据 Issue 内容生成。

描述

[Type] Code Quality iOS

Follow-ups from the review of #625. None of these block it.

1. A new credential reaches REST but not uploads

What happens: a host calls updateConfiguration(_:) with a new authHeader before the editor loads. REST requests use the new credential. Media uploads and deletes still use the one the editor was created with.

Who is affected: a host that refreshes an expired token this way. REST works, but every upload fails with a 401.

How this was checked: in the iOS 27.0 Simulator against wp-env, we created the editor with a valid credential, then updated it to a wrong one. REST got rest_forbidden. The upload got 201, so it went out with the old credential.

This is pre-existing: the old upload server also used the client built at init. But prepareNativeHandlers() now says it rebuilds the upload service "with the credential that the page is given", which isn't true for uploads.

Suggested fix: have InternalMediaClient set Authorization from configuration.authHeader on each request, or correct the doc comment.

2. A system file picker can appear for a mixed selection

What happens: if the host passes the inserter a selection where the first item has an id (a library item) and a later one is an imported file, the page clicks the native file input but never waits for the files. The native offer ends, and WebKit can show its own file picker.

Who is affected: only a host that mixes library items and imported files in one selection. The page already assumes selections are never mixed. Not reproduced.

Suggested fix: only call requestNativeFiles() on the path that uses the files, or make the "never mixed" rule hold.

3. Cleanups

  • MediaUpload.fileURL is deleted as soon as upload returns, but the docs don't say so. They mention an offline queue, so a host could store the URL and find the file gone. Document it.
  • A staged upload stays on disk if the page dies mid-upload and no cancel arrives. It is cleaned up at the next upload or when the editor is released, so this is bounded.
  • RestRelaySchemeHandler.cancelAll() is only called from tests, but its comment says "as a teardown would". Wire it into teardown, or delete it.
  • EditorViewController builds the relay and upload service in init, then rebuilds them on every load. Build them in one place.
  • In api-fetch.js, loopbackUpload sits before schemeUpload, which breaks the call-order convention in AGENTS.md.
主要语言
JavaScript
星标
29
派生
6
平均合并
2 天 1 小时
30 天内合并 PR
76

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wordpress-mobile/GutenbergKit 的其他 Issue

查看 wordpress-mobile/GutenbergKit 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。