Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 15776)
+++ wp-includes/query.php	(working copy)
@@ -2186,25 +2186,18 @@
 		// Apply post-paging filters on where and join.  Only plugins that
 		// manipulate paging queries should use these hooks.
 		if ( !$q['suppress_filters'] ) {
-			$distinct	= apply_filters_ref_array( 'posts_distinct',	array( $distinct, &$this ) );
-			$fields		= apply_filters_ref_array( 'posts_fields',		array( $fields, &$this ) );
-			$where		= apply_filters_ref_array( 'posts_where_paged',	array( $where, &$this ) );
-			$join		= apply_filters_ref_array( 'posts_join_paged',	array( $join, &$this ) );
-			$groupby	= apply_filters_ref_array( 'posts_groupby',		array( $groupby, &$this ) );
-			$orderby	= apply_filters_ref_array( 'posts_orderby',		array( $orderby, &$this ) );
-			$limits		= apply_filters_ref_array( 'post_limits',		array( $limits, &$this ) );	
-
-			// Also apply a filter on all clauses at once, for convenience
-			$clauses = array();
-			foreach ( array('distinct', 'fields', 'where', 'join', 'groupby', 'orderby', 'limits') as $var ) {
-				$clauses[ $var ] = $$var;
-				unset( $$var );	// so we can use EXTR_SKIP below
-			}
-
-			$clauses = apply_filters_ref_array( 'wp_query_clauses', array( $clauses, &$this ) );
-
-			extract( $clauses, EXTR_SKIP );
-			unset( $clauses );
+			$var_config = array(
+				'where'    => 'posts_where_paged',
+				'groupby'  => 'posts_groupby',
+				'join'     => 'posts_join_paged',
+				'orderby'  => 'posts_orderby',
+				'distinct' => 'posts_distinct',
+				'limits'   => 'post_limits',
+				'fields'   => 'posts_fields',
+			);
+			$var_values = compact( array_keys( $var_config ) );
+			$result = $this->_filter_clause_variables( $var_config, $var_values, 'posts_clauses' );
+			extract( $result );
 		}
 
 		// Announce current selection parameters.  For use by caching plugins.
@@ -2212,13 +2205,18 @@
 
 		// Filter again for the benefit of caching plugins.  Regular plugins should use the hooks above.
 		if ( !$q['suppress_filters'] ) {
-			$distinct	= apply_filters_ref_array( 'posts_distinct_request',array( $distinct, &$this ) );
-			$fields		= apply_filters_ref_array( 'posts_fields_request',	array( $fields, &$this ) );
-			$where		= apply_filters_ref_array( 'posts_where_request',	array( $where, &$this ) );
-			$join		= apply_filters_ref_array( 'posts_join_request',	array( $join, &$this ) );
-			$groupby	= apply_filters_ref_array( 'posts_groupby_request',	array( $groupby, &$this ) );
-			$orderby	= apply_filters_ref_array( 'posts_orderby_request',	array( $orderby, &$this ) );
-			$limits		= apply_filters_ref_array( 'post_limits_request',	array( $limits, &$this ) );
+			$var_config = array(
+				'where'    => 'posts_where_request',
+				'groupby'  => 'posts_groupby_request',
+				'join'     => 'posts_join_request',
+				'orderby'  => 'posts_orderby_request',
+				'distinct' => 'posts_distinct_request',
+				'fields'   => 'posts_fields_request',
+				'limits'   => 'post_limits_request',
+			);
+			$var_values = compact( array_keys( $var_config ) );
+			$result = $this->_filter_clause_variables( $var_config, $var_values, 'posts_clauses_request' );
+			extract( $result );
 		}
 
 		if ( ! empty($groupby) )
@@ -2361,6 +2359,29 @@
 	}
 
 	/**
+	 * filter clause variables based on configuration. once per clause and 
+	 * then all clauses at once.
+	 * 
+	 * @access private
+	 * @param array $config filternames keyed with their variable names
+	 * @param array $values values keyed with their variable names
+	 * @param string $all_filter_name for the "single filter"
+	 * @return array filtered values keyed with their names
+	 */
+	function _filter_clause_variables( $config, $values, $all_filter_name ) {
+		$clauses = array();
+		foreach ( $config as $variable_name => $filter ) {
+			$clauses[$variable_name] = apply_filters_ref_array( $filter, array( $values[$variable_name], &$this ) );
+		}
+		// run filter for all clauses at once
+		$clauses = apply_filters_ref_array( $all_filter_name, array( $clauses, &$this ) );
+		if ( is_array( $clauses ) && array_keys( $clauses ) === array_keys( $values ) ) {
+			$values = $clauses;
+		}
+		return $values;
+	}
+
+	/**
 	 * Set up the next post and iterate current post index.
 	 *
 	 * @since 1.5.0
