Index: src/wp-includes/query.php
===================================================================
--- src/wp-includes/query.php	(revision 36340)
+++ src/wp-includes/query.php	(working copy)
@@ -3531,28 +3531,53 @@
 		}
 
 		if ( 'ids' == $q['fields'] ) {
-			$this->posts = $wpdb->get_col( $this->request );
-			$this->posts = array_map( 'intval', $this->posts );
-			$this->post_count = count( $this->posts );
-			$this->set_found_posts( $q, $limits );
 
+			/**
+			 * Filter the query results when 'fields' specified in a query.
+			 *
+			 * Plugins can bypass a 'fields' query by returning
+			 * an array of posts to be returned from the query.
+			 *
+			 * @since 4.5.0
+			 *
+			 * @param array    $posts   The filtered array of posts.
+			 * @param array    $request The complete SQL query.
+			 * @param string   $fields  The query 'fields' value.
+			 * @param WP_Query &$this   The WP_Query instance (passed by reference).
+			 */
+			$this->posts = apply_filters_ref_array( 'fields_the_posts', array( false, $q['fields'], $this->request, &$this ) );
+
+			if ( false === $this->posts ) {
+				$this->posts = $wpdb->get_col( $this->request );
+				$this->posts = array_map( 'intval', $this->posts );
+				$this->post_count = count( $this->posts );
+				$this->set_found_posts( $q, $limits );
+			}
+
 			return $this->posts;
 		}
 
 		if ( 'id=>parent' == $q['fields'] ) {
-			$this->posts = $wpdb->get_results( $this->request );
-			$this->post_count = count( $this->posts );
-			$this->set_found_posts( $q, $limits );
+			/** This filter is documented in wp-includes/query.php */
+			$this->posts = apply_filters_ref_array( 'fields_the_posts', array( false, $q['fields'], $this->request, &$this ) );
 
-			$r = array();
-			foreach ( $this->posts as $key => $post ) {
-				$this->posts[ $key ]->ID = (int) $post->ID;
-				$this->posts[ $key ]->post_parent = (int) $post->post_parent;
+			if ( false === $this->posts ) {
+				$this->posts = $wpdb->get_results( $this->request );
+				$this->post_count = count( $this->posts );
+				$this->set_found_posts( $q, $limits );
 
-				$r[ (int) $post->ID ] = (int) $post->post_parent;
+				$r = array();
+				foreach ( $this->posts as $key => $post ) {
+					$this->posts[ $key ]->ID = (int) $post->ID;
+					$this->posts[ $key ]->post_parent = (int) $post->post_parent;
+
+					$r[ (int) $post->ID ] = (int) $post->post_parent;
+				}
+
+				$this->posts = $r;
 			}
 
-			return $r;
+			return $this->posts;
 		}
 
 		$split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
