WordPress.org

Make WordPress Core

Ticket #16556: exact-role-search.patch

File exact-role-search.patch, 1.4 KB (added by 082net, 7 years ago)
  • wp-admin/includes/user.php

     
    686686
    687687                if ( $this->role ) {
    688688                        $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
    689                         $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
     689                        $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%"' . $this->role . '"%');
    690690                } elseif ( is_multisite() ) {
    691691                        $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
    692692                        $this->query_from .= ", $wpdb->usermeta";
  • wp-includes/user.php

     
    456456                // Build a CPU-intensive query that will return concise information.
    457457                $select_count = array();
    458458                foreach ( $avail_roles as $this_role => $name ) {
    459                         $select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%" . like_escape($this_role) . "%', FALSE))";
     459                        $select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%\"" . like_escape($this_role) . "\"%', FALSE))";
    460460                }
    461461                $select_count = implode(', ', $select_count);
    462462