WordPressKit REST requests build the wrong URL on self-hosted sites that use plain permalinks
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 57/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Swift
- Star
- 3.9k
- Fork
- 1.2k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 136
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của wordpress-mobile/WordPress-iOS
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
wordpress-mobile/WordPress-iOS#26423 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Pri] Low [Status] Ready for Dev [Type] Bug /Me
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
wordpress-mobile/WordPress-iOS#26279 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Pri] Low [Status] Ready for Dev [Type] Bug Share Extension
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
wordpress-mobile/WordPress-iOS#26276 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Pri] Low [Status] Ready for Dev [Type] Bug Blogging Prompts Notifications
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
wordpress-mobile/WordPress-iOS#26256 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Status] Ready for Dev [Type] Bug Reader
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
wordpress-mobile/WordPress-iOS#26254 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của wordpress-mobile/WordPress-iOS
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Optional callbacks log "Unable to create JSCallback" when passed nullCó thể đã có người làm @cmsj đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
cmsj/Hammerspoon2#464 ·
-
android bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
VocaHQ/vocaphone#470 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
new-compilers request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
compiler-explorer/compiler-explorer#9640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
RevenueCat/purchases-ios#8312 ·
Maintainer thường phản hồi trong vòng 1 ngày