diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index 22a9639033..8abd2c1ec5 100644
a
|
b
|
function wp_get_users_with_no_role( $site_id = null ) { |
2708 | 2708 | } |
2709 | 2709 | |
2710 | 2710 | $regex = implode( '|', array_keys( $role_names ) ); |
2711 | | $regex = preg_replace( '/[^a-zA-Z_\|-]/', '', $regex ); |
| 2711 | $regex = preg_replace( '/[^0-9a-zA-Z_\|-]/', '', $regex ); |
2712 | 2712 | $users = $wpdb->get_col( |
2713 | 2713 | $wpdb->prepare( |
2714 | 2714 | " |
diff --git a/tests/phpunit/tests/user/wpGetUsersWithNoRole.php b/tests/phpunit/tests/user/wpGetUsersWithNoRole.php
index 46b8bafbdb..80a958a828 100644
a
|
b
|
class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { |
109 | 109 | * Role comparison must be done on role name, not role display name. |
110 | 110 | * |
111 | 111 | * @ticket 38234 |
| 112 | * @ticket 49399 |
112 | 113 | */ |
113 | 114 | public function test_get_users_with_no_role_matches_on_role_name() { |
114 | 115 | // Create a role with a display name which would not match the role name |
115 | 116 | // in a case-insentive SQL query. |
116 | 117 | wp_roles()->add_role( 'somerole', 'Some role display name' ); |
| 118 | wp_roles()->add_role( 'role2', 'Another role with display name' ); |
| 119 | wp_roles()->add_role( 'Group1Admins', 'group admin' ); |
117 | 120 | |
118 | 121 | $someuser = self::factory()->user->create( |
119 | 122 | array( |
… |
… |
class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { |
121 | 124 | ) |
122 | 125 | ); |
123 | 126 | |
| 127 | $someuser2 = self::factory()->user->create( |
| 128 | array( |
| 129 | 'role' => 'role2', |
| 130 | ) |
| 131 | ); |
| 132 | |
| 133 | $someuser3 = self::factory()->user->create( |
| 134 | array( |
| 135 | 'role' => 'Group1Admins', |
| 136 | ) |
| 137 | ); |
| 138 | |
124 | 139 | $users = wp_get_users_with_no_role(); |
125 | 140 | |
126 | 141 | wp_roles()->remove_role( 'somerole' ); |
| 142 | wp_roles()->remove_role( 'role2' ); |
| 143 | wp_roles()->remove_role( 'Group1Admins' ); |
127 | 144 | |
128 | 145 | $this->assertEmpty( $users ); |
129 | 146 | } |