Ticket #21426: 21426.diff
File 21426.diff, 2.7 KB (added by , 13 years ago) |
---|
-
wp-includes/user.php
314 314 class WP_User_Query { 315 315 316 316 /** 317 * Query vars, after parsing 318 * 319 * @since 3.5.0 320 * @access public 321 * @var array 322 */ 323 var $query_vars = array(); 324 325 /** 317 326 * List of found user ids 318 327 * 319 328 * @since 3.1.0 … … 381 390 function prepare_query() { 382 391 global $wpdb; 383 392 384 $qv = &$this->query_vars;393 $qv =& $this->query_vars; 385 394 386 395 if ( is_array( $qv['fields'] ) ) { 387 396 $qv['fields'] = array_unique( $qv['fields'] ); … … 396 405 $this->query_fields = "$wpdb->users.ID"; 397 406 } 398 407 399 if ( $ this->query_vars['count_total'] )408 if ( $qv['count_total'] ) 400 409 $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; 401 410 402 411 $this->query_from = "FROM $wpdb->users"; … … 528 537 function query() { 529 538 global $wpdb; 530 539 531 if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) { 540 $qv =& $this->query_vars; 541 542 if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { 532 543 $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 533 544 } else { 534 545 $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 535 546 } 536 547 537 if ( $ this->query_vars['count_total'] )548 if ( $qv['count_total'] ) 538 549 $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); 539 550 540 551 if ( !$this->results ) 541 552 return; 542 553 543 if ( 'all_with_meta' == $ this->query_vars['fields'] ) {554 if ( 'all_with_meta' == $qv['fields'] ) { 544 555 cache_users( $this->results ); 545 556 546 557 $r = array(); 547 558 foreach ( $this->results as $userid ) 548 $r[ $userid ] = new WP_User( $userid, '', $ this->query_vars['blog_id'] );559 $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] ); 549 560 550 561 $this->results = $r; 551 562 } 552 563 } 553 564 565 /** 566 * Retrieve query variable. 567 * 568 * @since 3.5.0 569 * @access public 570 * 571 * @param string $query_var Query variable key. 572 * @return mixed 573 */ 574 function get( $query_var ) { 575 if ( isset( $this->query_vars[$query_var] ) ) 576 return $this->query_vars[$query_var]; 577 578 return null; 579 } 580 581 /** 582 * Set query variable. 583 * 584 * @since 3.5.0 585 * @access public 586 * 587 * @param string $query_var Query variable key. 588 * @param mixed $value Query variable value. 589 */ 590 function set( $query_var, $value ) { 591 $this->query_vars[$query_var] = $value; 592 } 593 554 594 /* 555 595 * Used internally to generate an SQL string for searching across multiple columns 556 596 *