Ticket #35476: fields-the-posts.diff
| File fields-the-posts.diff, 2.0 KB (added by , 10 years ago) |
|---|
-
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 ); 3534 $this->posts = apply_filters( 'fields_the_posts', false, $q['fields'], $this->request, &$this ); 3538 3535 3536 if ( false === $this->posts ) { 3537 $this->posts = $wpdb->get_col( $this->request ); 3538 $this->posts = array_map( 'intval', $this->posts ); 3539 $this->post_count = count( $this->posts ); 3540 $this->set_found_posts( $q, $limits ); 3541 } 3542 3539 3543 return $this->posts; 3540 3544 } 3541 3545 3542 3546 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 ); 3547 $this->posts = apply_filters( 'fields_the_posts', false, $q['fields'], $this->request, &$this ); 3546 3548 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;3549 if ( false === $this->posts ) { 3550 $this->posts = $wpdb->get_results( $this->request ); 3551 $this->post_count = count( $this->posts ); 3552 $this->set_found_posts( $q, $limits ); 3551 3553 3552 $r[ (int) $post->ID ] = (int) $post->post_parent; 3554 $r = array(); 3555 foreach ( $this->posts as $key => $post ) { 3556 $this->posts[ $key ]->ID = (int) $post->ID; 3557 $this->posts[ $key ]->post_parent = (int) $post->post_parent; 3558 3559 $r[ (int) $post->ID ] = (int) $post->post_parent; 3560 } 3561 3562 $this->posts = $r; 3553 3563 } 3554 3564 3555 return $ r;3565 return $this->posts; 3556 3566 } 3557 3567 3558 3568 $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );