Ticket #35476: 35476.diff
| File 35476.diff, 2.6 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/query.php
3531 3531 } 3532 3532 3533 3533 if ( 'ids' == $q['fields'] ) { 3534 $this->posts = $wpdb->get_col( $this->request );3535 $this->posts = array_map( 'intval', $this->posts );3536 $this->post_count = count( $this->posts );3537 $this->set_found_posts( $q, $limits );3538 3534 3535 /** 3536 * Filter the query results when 'fields' specified in a query. 3537 * 3538 * Plugins can bypass a 'fields' query by returning 3539 * an array of posts to be returned from the query. 3540 * 3541 * @since 4.5.0 3542 * 3543 * @param array $posts The filtered array of posts. 3544 * @param array $request The complete SQL query. 3545 * @param string $fields The query 'fields' value. 3546 * @param WP_Query &$this The WP_Query instance (passed by reference). 3547 */ 3548 $this->posts = apply_filters_ref_array( 'fields_the_posts', array( false, $q['fields'], $this->request, &$this ) ); 3549 3550 if ( false === $this->posts ) { 3551 $this->posts = $wpdb->get_col( $this->request ); 3552 $this->posts = array_map( 'intval', $this->posts ); 3553 $this->post_count = count( $this->posts ); 3554 $this->set_found_posts( $q, $limits ); 3555 } 3556 3539 3557 return $this->posts; 3540 3558 } 3541 3559 3542 3560 if ( 'id=>parent' == $q['fields'] ) { 3543 $this->posts = $wpdb->get_results( $this->request ); 3544 $this->post_count = count( $this->posts ); 3545 $this->set_found_posts( $q, $limits ); 3561 /** This filter is documented in wp-includes/query.php */ 3562 $this->posts = apply_filters_ref_array( 'fields_the_posts', array( false, $q['fields'], $this->request, &$this ) ); 3546 3563 3547 $r = array();3548 foreach ( $this->posts as $key => $post ) {3549 $this->post s[ $key ]->ID = (int) $post->ID;3550 $this-> posts[ $key ]->post_parent = (int) $post->post_parent;3564 if ( false === $this->posts ) { 3565 $this->posts = $wpdb->get_results( $this->request ); 3566 $this->post_count = count( $this->posts ); 3567 $this->set_found_posts( $q, $limits ); 3551 3568 3552 $r[ (int) $post->ID ] = (int) $post->post_parent; 3569 $r = array(); 3570 foreach ( $this->posts as $key => $post ) { 3571 $this->posts[ $key ]->ID = (int) $post->ID; 3572 $this->posts[ $key ]->post_parent = (int) $post->post_parent; 3573 3574 $r[ (int) $post->ID ] = (int) $post->post_parent; 3575 } 3576 3577 $this->posts = $r; 3553 3578 } 3554 3579 3555 return $ r;3580 return $this->posts; 3556 3581 } 3557 3582 3558 3583 $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );