Repository navigation
Abilities: Sync core/users-query with WordPress core - #1207
Conversation
Apply the changes that shipped with the `core/users-query` ability in WordPress core (r64346, Trac #64657): - The input has three members: `where` selects the users, `fields` the fields returned for each user, and `pagination` the page. - `where` filters by `ids`, `slugs`, `usernames`, `roles`, or `has_published_posts`. The single-user lookups by `id`, `email`, `username`, and `slug` are removed. - The output always holds the users in `items` and the totals in `pagination`. Results are ordered by username. - Filters that cannot be honored are rejected instead of dropped, and a page past the last one returns a 404 error. - Filtering by username requires permission to list users. - The REST run endpoint tests from core are ported as well.
The `core/read-users` alias can no longer keep the old input and output contract after syncing `core/users-query` with WordPress core, so it is removed. Use `core/users-query` with the new `where`, `fields`, and `pagination` input instead.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1207 +/- ##
=============================================
+ Coverage 84.18% 84.24% +0.05%
+ Complexity 3516 3497 -19
=============================================
Files 139 139
Lines 13484 13440 -44
=============================================
- Hits 11351 11322 -29
+ Misses 2133 2118 -15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
What?
See #64657, r64346.
This PR syncs the
core/users-queryability with the version that landed in WordPress core. The plugin acts as a polyfill until WordPress 7.2 is out. It also removes the deprecatedcore/read-usersalias.Why?
The ability was first built in this plugin (#774) and then moved to WordPress core. During the core review, the input and output shape changed a lot. The plugin should behave the same as core, so code written for the plugin keeps working on WordPress 7.2.
The old alias cannot keep the old contract after these changes, so it is removed. This is the same as what #1206 does for
core/read-settings.How?
The PR has two commits:
includes/Abilities/Users/Users.phpis now a copy of the core classWP_Abilities_Users. Each difference from core is marked with a// Plugin:comment: theinit()method, unregistering the copy from core, an explicitshow_in_rest, and theaitext domain.core/read-usersis no longer registered.These are breaking changes for callers:
{ where, fields, pagination }.wheretakesids,slugs,usernames,roles, andhas_published_posts. The old root-levelid,email,username,slug,include,page, andper_pageare removed. Lookup by email is no longer supported.{ items, pagination: { total, total_pages } }. A single user is no longer returned as a bare object.Tests:
UsersTest.phpis ported from the core testwpRegisterCoreUsersAbility.php. It also keeps two tests that only the plugin needs.Users_RestTest.phpis new. It is ported from the core testwpRestAbilitiesUsersController.phpand runs the ability through the REST run endpoint.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Comparing the core commit with the plugin, porting the code and tests, updating the e2e spec, and running the checks. I reviewed the diff and the test results.
Testing Instructions
npm run test:php -- --filter Users.npx wp-env --config=.wp-env.test.json run cli --env-cwd=wp-content/plugins/ai bash -c "WP_MULTISITE=1 vendor/bin/phpunit -c phpunit.xml.dist --filter Users".npx wp-env --config=.wp-env.test.json run cli wp plugin activate ai. Then runnpx wp-scripts test-playwright --config tests/e2e/playwright.config.ts tests/e2e/specs/abilities/core-users-query.spec.js.core/users-querywith{ "where": { "roles": [ "administrator" ] }, "fields": [ "id", "name" ] }and check that the result hasitemsandpagination.Changelog Entry
🤖 Generated with Claude Code