Changeset 35707
- Timestamp:
- 11/19/2015 05:10:47 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/user-functions.php (modified) (2 diffs)
-
tests/phpunit/tests/user/countUsers.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user-functions.php
r35630 r35707 759 759 $select_count[] = $wpdb->prepare( "COUNT(NULLIF(`meta_value` LIKE %s, false))", '%' . $wpdb->esc_like( '"' . $this_role . '"' ) . '%'); 760 760 } 761 $select_count[] = "COUNT(NULLIF(`meta_value` = 'a:0:{}', false))"; 761 762 $select_count = implode(', ', $select_count); 762 763 … … 774 775 } 775 776 777 $role_counts['none'] = (int) $row[$col++]; 778 776 779 // Get the meta_value index from the end of the result set. 777 780 $total_users = (int) $row[$col]; 778 779 $role_counts['none'] = ( $total_users - array_sum( $role_counts ) );780 781 781 782 $result['total_users'] = $total_users; -
trunk/tests/phpunit/tests/user/countUsers.php
r35242 r35707 141 141 } 142 142 143 /** 144 * @ticket 34495 145 * 146 * @dataProvider data_count_users_strategies 147 */ 148 public function test_count_users_is_accurate_with_multiple_roles( $strategy ) { 149 150 // Setup users 151 $admin = self::factory()->user->create( array( 152 'role' => 'administrator', 153 ) ); 154 $editor = self::factory()->user->create( array( 155 'role' => 'editor', 156 ) ); 157 158 get_userdata( $editor )->add_role( 'author' ); 159 160 $this->assertEquals( array( 161 'editor', 162 'author' 163 ), get_userdata( $editor )->roles ); 164 165 // Test user counts 166 $count = count_users( $strategy ); 167 168 $this->assertEquals( 3, $count['total_users'] ); 169 $this->assertEquals( array( 170 'administrator' => 2, 171 'editor' => 1, 172 'author' => 1, 173 'none' => 0, 174 ), $count['avail_roles'] ); 175 176 } 177 143 178 function data_count_users_strategies() { 144 179 return array(
Note: See TracChangeset
for help on using the changeset viewer.