Fix #1313: extra_capabilities parsing issue in the /wp/v2/users response#1314
Merged
crazytonyli merged 4 commits intotrunkfrom May 4, 2026
Merged
Fix #1313: extra_capabilities parsing issue in the /wp/v2/users response#1314crazytonyli merged 4 commits intotrunkfrom
extra_capabilities parsing issue in the /wp/v2/users response#1314crazytonyli merged 4 commits intotrunkfrom
Conversation
Collaborator
XCFramework BuildThis PR's XCFramework is available for testing. Add to your .package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1314")Built from dc1932e |
oguzkocer
approved these changes
May 4, 2026
Add two fixture admin users to the integration test setup whose
`wp_capabilities` usermeta is poisoned via `wp eval` to exercise the two
non-bool shapes that break clients today:
- `legacy_admin` carries `{"administrator": "1"}`, mimicking pre-2012 WP
sites whose role assignments were written as the string `"1"`. This is
the exact failure mode reported in #1313 — the iOS app cannot parse
`users/me?context=edit` for these users.
- `wpbakery_admin` carries
`{"administrator": true, "vc_access_rules_post_types": "custom"}`,
mimicking plugins that call `WP_User::add_cap($cap, $grant)` with
non-bool grants. PR #1263 already fixed this on `capabilities` with a
unit test; this gives it integration coverage too.
Tests fetch each user by ID via the default admin client and rely on
`assert_response()` to surface deserialization failures. Both fail
today on `extra_capabilities`, which is still typed
`Option<HashMap<String, bool>>`. The fix follows in the next commit.
Switch `SparseUser::extra_capabilities` from `Option<HashMap<String, bool>>` to `Option<UserCapabilitiesMap>`, mirroring the wrapper PR #1263 introduced for the sibling `capabilities` field. The underlying `HashMap<UserCapability, JsonValue>` tolerates the non-bool shapes that legacy WordPress and plugins like WPBakery write into `wp_capabilities` usermeta, and the existing `has_cap()` helper preserves the boolean-check semantics callers expect. Tighten the integration tests added in the previous commit to assert both the raw map contents and `has_cap()` behavior on the now-rich wrapper type. This is a Swift/Kotlin binding change consistent with PR #1263: `UserWithEditContext.extraCapabilities` becomes `UserCapabilitiesMap` instead of `[String: Bool]`. Fixes #1313.
Document the breaking type change and the underlying bug fix from the preceding commit. Mirrors the conventions used for the analogous breaking changes elsewhere in the Unreleased section.
The fixture admin users `legacy_admin` and `wpbakery_admin` introduced earlier in this branch raise the total user count on the test site from 4 to 6, which broke `UsersEndpointTest.testUserListRequest` and `testFilterUserListRequest`. Bump `NUMBER_OF_USERS` to 6 and split out `NUMBER_OF_USERS_WITH_PUBLISHED_POSTS` so the `testUserListRequestWithHasPublishedPostsParam` assertion no longer relies on the incidental `NUMBER_OF_USERS - 1` arithmetic — adding more non-publishing fixture users in the future no longer silently desyncs that test.
abf7a41 to
dc1932e
Compare
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.
Description
Use the same approach in #1263, with integration tests for #1313 and #1263