Ticket #21426: user-query-get-set.diff
File user-query-get-set.diff, 2.7 KB (added by , 13 years ago) |
---|
-
wp-includes/user.php
333 333 * @since 3.1.0 334 334 */ 335 335 class WP_User_Query { 336 337 336 /** 337 * Query vars, after parsing 338 * 339 * @since 3.5.0 340 * @access public 341 * @var array 342 */ 343 var $query_vars = array(); 344 345 /** 338 346 * List of found user ids 339 347 * 340 348 * @since 3.1.0 … … 402 410 function prepare_query() { 403 411 global $wpdb; 404 412 405 $qv = &$this->query_vars;413 $qv =& $this->query_vars; 406 414 407 415 if ( is_array( $qv['fields'] ) ) { 408 416 $qv['fields'] = array_unique( $qv['fields'] ); … … 417 425 $this->query_fields = "$wpdb->users.ID"; 418 426 } 419 427 420 if ( $ this->query_vars['count_total'] )428 if ( $qv['count_total'] ) 421 429 $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; 422 430 423 431 $this->query_from = "FROM $wpdb->users"; … … 549 557 function query() { 550 558 global $wpdb; 551 559 552 if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) { 560 $qv =& $this->query_vars; 561 562 if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { 553 563 $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 554 564 } else { 555 565 $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 556 566 } 557 567 558 if ( $ this->query_vars['count_total'] )568 if ( $qv['count_total'] ) 559 569 $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); 560 570 561 571 if ( !$this->results ) 562 572 return; 563 573 564 if ( 'all_with_meta' == $ this->query_vars['fields'] ) {574 if ( 'all_with_meta' == $qv['fields'] ) { 565 575 cache_users( $this->results ); 566 576 567 577 $r = array(); 568 578 foreach ( $this->results as $userid ) 569 $r[ $userid ] = new WP_User( $userid, '', $ this->query_vars['blog_id'] );579 $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] ); 570 580 571 581 $this->results = $r; 572 582 } 573 583 } 574 584 585 /** 586 * Retrieve query variable. 587 * 588 * @since 3.5.0 589 * @access public 590 * 591 * @param string $query_var Query variable key. 592 * @return mixed 593 */ 594 function get( $query_var ) { 595 if ( isset( $this->query_vars[$query_var] ) ) 596 return $this->query_vars[$query_var]; 597 598 return ''; 599 } 600 601 /** 602 * Set query variable. 603 * 604 * @since 3.5.0 605 * @access public 606 * 607 * @param string $query_var Query variable key. 608 * @param mixed $value Query variable value. 609 */ 610 function set( $query_var, $value ) { 611 $this->query_vars[$query_var] = $value; 612 } 613 575 614 /* 576 615 * Used internally to generate an SQL string for searching across multiple columns 577 616 *