Changeset 34531
- Timestamp:
- 09/25/2015 04:25:20 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-user-query.php
r34393 r34531 84 84 * for `$orderby` parameter. 85 85 * @since 4.3.0 Added 'has_published_posts' parameter. 86 * @since 4.4.0 Added 'paged' parameter. 86 87 * @access public 87 88 * … … 125 126 * conjunction with pagination. Value -1 (all) is not supported. 126 127 * Default empty (all users). 128 * @type int $paged When used with number, defines the page of results to return. 129 * Default 1. 127 130 * @type bool $count_total Whether to count the total number of users found. If pagination 128 131 * is not needed, setting this to false can improve performance. … … 158 161 'offset' => '', 159 162 'number' => '', 163 'paged' => 1, 160 164 'count_total' => true, 161 165 'fields' => 'all', … … 324 328 // limit 325 329 if ( isset( $qv['number'] ) && $qv['number'] ) { 326 if ( $qv['offset'] ) 330 if ( $qv['offset'] ) { 327 331 $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']); 328 else 329 $this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']); 332 } else { 333 $this->query_limit = $wpdb->prepare( "LIMIT %d, %d", $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] ); 334 } 330 335 } 331 336 -
trunk/tests/phpunit/tests/user/query.php
r32713 r34531 460 460 $query->prepare_query( array( 'number' => 8 ) ); 461 461 $this->assertNotEmpty( $query->query_limit ); 462 $this->assertEquals( 'LIMIT 8', $query->query_limit );462 $this->assertEquals( 'LIMIT 0, 8', $query->query_limit ); 463 463 464 464 // All values get reset … … 858 858 $this->assertEqualSets( $expected, $found ); 859 859 } 860 861 /** 862 * @ticket 25145 863 */ 864 public function test_paged() { 865 $users = $this->factory->user->create_many( 5 ); 866 867 $q = new WP_User_Query( array( 868 'number' => 2, 869 'paged' => 2, 870 'orderby' => 'ID', 871 'order' => 'DESC', // Avoid funkiness with user 1. 872 'fields' => 'ids', 873 ) ); 874 875 $this->assertEquals( array( $users[2], $users[1] ), $q->results ); 876 } 860 877 }
Note: See TracChangeset
for help on using the changeset viewer.