Ticket #21119: 21119.2.diff
File 21119.2.diff, 2.2 KB (added by , 11 years ago) |
---|
-
src/wp-includes/user.php
431 431 * @return WP_User_Query 432 432 */ 433 433 function __construct( $query = null ) { 434 if ( !empty( $query ) ) { 434 if ( ! empty( $query ) ) { 435 $this->prepare_query( $query ); 436 $this->query(); 437 } 438 } 439 440 /** 441 * Prepare the query variables 442 * 443 * @since 3.1.0 444 * 445 * @param string|array $args The query variables 446 */ 447 function prepare_query( $query = array() ) { 448 global $wpdb; 449 450 if ( empty( $this->query_vars ) || ! empty( $query ) ) { 435 451 $this->query_vars = wp_parse_args( $query, array( 436 452 'blog_id' => $GLOBALS['blog_id'], 437 453 'role' => '', … … 450 466 'fields' => 'all', 451 467 'who' => '' 452 468 ) ); 453 454 $this->prepare_query();455 $this->query();456 469 } 457 }458 470 459 /**460 * Prepare the query variables461 *462 * @since 3.1.0463 * @access private464 */465 function prepare_query() {466 global $wpdb;467 468 471 $qv =& $this->query_vars; 469 472 470 473 if ( is_array( $qv['fields'] ) ) { … … 649 652 * Execute the query, with the current variables 650 653 * 651 654 * @since 3.1.0 652 * @access private653 655 */ 654 656 function query() { 655 657 global $wpdb; 656 658 657 659 $qv =& $this->query_vars; 658 660 661 $query = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; 662 659 663 if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { 660 $this->results = $wpdb->get_results( "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");664 $this->results = $wpdb->get_results( $query ); 661 665 } else { 662 $this->results = $wpdb->get_col( "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");666 $this->results = $wpdb->get_col( $query ); 663 667 } 664 668 665 669 /** -
tests/phpunit/tests/user/query.php
43 43 44 44 $ids = $users->get_results(); 45 45 $this->assertEquals( array( $this->user_id ), $ids ); 46 47 46 } 48 47 49 48 function test_exclude() {