Commit 4cfbbc6c7b for wordpress.org

commit 4cfbbc6c7b6f0b88b846fcac9f1bf41cd521b307
Author: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Date:   Fri Nov 20 15:47:57 2026 +0000

    Abilities API: Reject empty slugs and usernames in `core/users-query`.

    The items of the `slugs` and `usernames` filters 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. A slug or username made only of whitespace names no user, so it is dropped before the query, and a list holding only such a value fails with `users_invalid_filter`.

    Developed in https://github.com/WordPress/wordpress-develop/pull/15986.

    Follow-up to [64346].

    Props jorgefilipecosta, gziolo.
    Fixes #64657.
    Built from https://develop.svn.wordpress.org/trunk@65726


    git-svn-id: http://core.svn.wordpress.org/trunk@64756 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/abilities/class-wp-abilities-users.php b/wp-includes/abilities/class-wp-abilities-users.php
index a0f21de801..51df002dfe 100644
--- a/wp-includes/abilities/class-wp-abilities-users.php
+++ b/wp-includes/abilities/class-wp-abilities-users.php
@@ -612,8 +612,10 @@ final class WP_Abilities_Users {
 	 * Accepts arrays and CSV strings, which it parses with wp_parse_list(), as schema
 	 * validation does. Schema validation accepts a CSV string for an array, and only the
 	 * REST run controller converts input to the schema types, so callers that bypass it,
-	 * such as a direct WP_Ability::execute() call, can pass one. Empty and duplicate
-	 * items need no handling here, because validation has already rejected them.
+	 * such as a direct WP_Ability::execute() call, can pass one. Empty and whitespace-only
+	 * strings name nothing, so they are dropped, and a list that holds only such strings
+	 * comes back empty. Duplicate items need no handling here, because validation has
+	 * already rejected them.
 	 *
 	 * @since 7.2.0
 	 *
@@ -625,7 +627,12 @@ final class WP_Abilities_Users {
 			return array();
 		}

-		return array_values( array_filter( wp_parse_list( $value ), 'is_string' ) );
+		return array_values(
+			array_filter(
+				wp_parse_list( $value ),
+				static fn( $item ) => is_string( $item ) && '' !== trim( $item )
+			)
+		);
 	}

 	/**
@@ -703,7 +710,8 @@ final class WP_Abilities_Users {
 							'minItems'    => 1,
 							'maxItems'    => self::MAX_PER_PAGE,
 							'items'       => array(
-								'type' => 'string',
+								'type'      => 'string',
+								'minLength' => 1,
 							),
 							'description' => __( 'Limit results to users with these slugs. If `pagination.per_page` is omitted, every matching user is returned on the first page.' ),
 						),
@@ -713,7 +721,8 @@ final class WP_Abilities_Users {
 							'minItems'    => 1,
 							'maxItems'    => self::MAX_PER_PAGE,
 							'items'       => array(
-								'type' => 'string',
+								'type'      => 'string',
+								'minLength' => 1,
 							),
 							'description' => __( 'Limit results to users with these usernames. Requires permission to list users. If `pagination.per_page` is omitted, every matching user is returned on the first page.' ),
 						),
diff --git a/wp-includes/version.php b/wp-includes/version.php
index e730e3e7de..6e272b03b8 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-RC2-65725';
+$wp_version = '7.2-RC2-65726';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.