Skip to content

Users query: Reject empty slugs and usernames - #1380

Merged
dkotter merged 1 commit into
developfrom
fix/users-query-empty-identifiers
Nov 13, 2026
Merged

dkotter merged 1 commit into
developfrom
fix/users-query-empty-identifiers

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What?

Port of WordPress/wordpress-develop#15986.

This PR makes the slugs and usernames filters of core/users-query reject an empty string, like the slugs filter of core/content-query:

  • The items of where.slugs and where.usernames require at least one character (minLength: 1).
  • slugs: [""] and usernames: [""] used to pass validation and return an empty list. They now fail with ability_invalid_input, also when the list holds a valid value next to the empty one.
  • Without schema validation, the execute callback drops empty strings from its list filters, so a list holding only "" fails with users_invalid_filter instead of being queried.

Why?

The plugin should keep behaving like core. The core PR is not committed yet.

How?

  • includes/Abilities/Users/Users.php: the core changes.
  • UsersTest.php: the core test changes, with @since x.x.x in place of @ticket.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: porting the core change and tests; reviewed by me.

Testing Instructions

Verify unit tests are passing:

vendor/bin/phpunit --filter '/\\Users(_Rest)?Test::/'

Or, on WordPress 7.1 or earlier (on 7.2, core provides the ability), run the ability in the editor console as an administrator:

wp.apiFetch( { path: wp.url.addQueryArgs( '/wp-abilities/v1/abilities/core/users-query/run', { input: { where: { slugs: [ '' ] } } } ) } );

Before: {"items":[],"pagination":{"total":0,"total_pages":0}}
After: ability_invalid_input, "Reason: input[where][slugs][0] must be at least 1 character long."

The same applies to usernames: [ '' ]. A slug that names a user, such as slugs: [ 'admin' ] (substitute a slug from your site), still returns that user.

Changelog Entry

Fixed - The slugs and usernames filters of core/users-query reject an empty string.

Open WordPress Playground Preview

Port of WordPress/wordpress-develop#15986.

The items of the `slugs` and `usernames` filters of `core/users-query` now require at least one character, like the `slugs` filter of `core/content-query`, so a list holding an empty string fails schema validation instead of returning an empty list.

Without schema validation, a slug or username list that holds only an empty string now fails with `users_invalid_filter` instead of being queried. An empty string next to another value is dropped.
@jorgefilipecosta
jorgefilipecosta requested a review from a team November 13, 2026 19:03
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.49%. Comparing base (7a6a0e5) to head (d052e52).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #1380   +/-   ##
==========================================
  Coverage      85.49%   85.49%           
- Complexity      4807     4808    +1     
==========================================
  Files            188      188           
  Lines          17734    17740    +6     
==========================================
+ Hits           15161    15167    +6     
  Misses          2573     2573           
Flag Coverage Δ
unit 85.49% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter added this to the 1.6.0 milestone Nov 13, 2026
@dkotter
dkotter merged commit bd73938 into develop Nov 13, 2026
36 checks passed
@dkotter
dkotter deleted the fix/users-query-empty-identifiers branch November 13, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants