WordPressKit REST requests build the wrong URL on self-hosted sites that use plain permalinks
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Read Modules/Sources/WordPressKit/WordPressOrgRestApi.swift and Modules/Sources/WordPressKit/HTTPRequestBuilder.swift, then trace how dotOrgRESTAPI and appendURLString handle the discovered query-form REST root. Check the existing URL resolver behavior mentioned in the issue and inspect relevant tests. Done means plain-permalink requests target https://site/index.php?rest_route=/wp/v2/… with request query parameters merged correctly, while path-based REST roots continue to work.
索引モデルが issue の本文から書いたものです。
説明
Description
WordPressOrgRestApi assumes a path-based REST root, so on a self-hosted site with plain permalinks it crashes debug builds and, in release builds, sends requests to the wrong resource.
- The root comes from discovery unchanged.
WordPressOrgRestApi(blog:)usesBlog.selfHostedRestApiRootURL, which isrestApiRootURLfrom REST API discovery. On a plain-permalink site that is the query form, e.g.https://site/index.php?rest_route=/. - Debug builds hit an assertion.
init(selfHostedSiteWPJSONURL:…)assertsapiURL.lastPathComponent == "wp-json", anddotOrgRESTAPIasserts the same. - Release builds append routes to the path.
HTTPRequestBuilder.dotOrgRESTAPI→appendURLStringadds the route to the URL path, producinghttps://site/index.php/wp/v2/…?rest_route=/. - WordPress answers that URL with the API index. The trailing
?rest_route=/routes to the REST index, so the request returns 200 with the API index instead of the requested resource. GutenbergKit hit the same silent failure (wordpress-mobile/GutenbergKit#563).
Affected callers include BlockEditorSettingsService, ApplicationPasswordRepository, PluginStore, GutenbergNetworking and JetpackConnectionWebViewController (via Blog.selfHostedSiteRestApi).
The expected URL is https://site/index.php?rest_route=/wp/v2/…, with any request query merged using &. That's what wordpress-rs (WpOrgSiteApiUrlResolver), GutenbergKit (wordpress-mobile/GutenbergKit#573) and #25859 now produce. Longer term, wordpress-mobile/GutenbergKit#579 proposes moving these joins onto the wordpress-rs resolver rather than adding another copy.
Related: #25604 (self-hosted login on plain-permalink sites); ApplicationPasswordRepository.createPassword builds a WordPressOrgRestApi for self-hosted sites, so login can reach this path.
Step-by-step reproduction instructions
- Use a self-hosted site set to Settings ▸ Permalinks ▸ Plain. Confirm its
Linkheader advertises?rest_route=/:curl -sI https://your-site.com/ | grep -i '^link'. - Sign in to the site in a debug build with an application password.
- Observe the assertion failure below.
Screenshots, screen recording, code snippet
Debug build, signed in to a plain-permalink site:
WordPressKit/WordPressOrgRestApi.swift:52: Assertion failed: Not a REST API URL: https://example.com/index.php?rest_route=/
The URL a release build would request (the route path-appended, per appendURLString) returns the API index, while the correct form returns the resource:
GET /index.php/wp/v2/types?rest_route=/ -> 200 {"name":…,"namespaces":[…],…} # REST API index
GET /index.php?rest_route=/wp/v2/types -> 200 {"post":…,"page":…,…} # post types
Relevant code on trunk:
Modules/Sources/WordPressKit/WordPressOrgRestApi.swift: bothwp-jsonasserts, anddotOrgRESTAPIModules/Sources/WordPressKit/HTTPRequestBuilder.swift:appendURLStringModules/Sources/WordPressData/Swift/Blog+SelfHostedRestApi.swift:selfHostedRestApiRootURL
Environment info
WordPress-iOS trunk (bbb4da2b3d), debug build; self-hosted site with plain permalinks, signed in with an application password.
Please confirm that you have searched existing issues in the repo.
- Yes
- 主要言語
- Swift
- スター
- 3.9k
- フォーク
- 1.2k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 136
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
wordpress-mobile/WordPress-iOS のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
wordpress-mobile/WordPress-iOS#26423 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Pri] Low [Status] Ready for Dev [Type] Bug /Me
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
wordpress-mobile/WordPress-iOS#26279 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Pri] Low [Status] Ready for Dev [Type] Bug Share Extension
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
wordpress-mobile/WordPress-iOS#26276 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Pri] Low [Status] Ready for Dev [Type] Bug Blogging Prompts Notifications
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
wordpress-mobile/WordPress-iOS#26256 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Status] Ready for Dev [Type] Bug Reader
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
wordpress-mobile/WordPress-iOS#26254 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
wordpress-mobile/WordPress-iOS の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
🎉 Add RemoteCrabオープン
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
jaywcjlove/awesome-mac#4999 ·
メンテナーはふだん 1 日以内に返信
-
[Type] Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
wordpress-mobile/GutenbergKit#940 ·
メンテナーはふだん 1 日以内に返信
-
pending-maintainer-response pending-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws-amplify/amplify-swift#4423 ·
メンテナーはふだん 2 日以内に返信
-
tests
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
erkamyaman/unslop-anything#80 ·
メンテナーはふだん 1 日以内に返信