Ticket #14997: 14997-notices.patch
| File 14997-notices.patch, 2.9 KB (added by , 16 years ago) |
|---|
-
wp-includes/query.php
2186 2186 // Apply post-paging filters on where and join. Only plugins that 2187 2187 // manipulate paging queries should use these hooks. 2188 2188 if ( !$q['suppress_filters'] ) { 2189 $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); 2190 $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); 2191 $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); 2192 $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); 2193 $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); 2194 $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); 2195 $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); 2196 2197 // Also apply a filter on all clauses at once, for convenience 2189 // clause filter variables 2190 $variables = array( 2191 'distinct' => 'posts_distinct', 2192 'fields' => 'posts_fields', 2193 'where' => 'posts_where_paged', 2194 'join' => 'posts_join_paged', 2195 'groupby' => 'posts_groupby', 2196 'orderby' => 'posts_orderby', 2197 'limits' => 'post_limits', 2198 ); 2199 // build clauses array and run filters once per clause 2198 2200 $clauses = array(); 2199 foreach ( array('distinct', 'fields', 'where', 'join', 'groupby', 'orderby', 'limits') as $var) {2200 $clauses[ $var ] = $$var;2201 unset( $$var ); // so we can use EXTR_SKIP below2201 foreach ( $variables as $variable_name => $filter_name ) { 2202 $clauses[ $variable_name ] = apply_filters_ref_array( $filter_name, array( $$variable_name, &$this ) ); 2203 unset( $$variable_name ); // for extract() with EXTR_SKIP parameter 2202 2204 } 2203 2205 // run filter for all clauses at once 2204 2206 $clauses = apply_filters_ref_array( 'wp_query_clauses', array( $clauses, &$this ) ); 2205 2206 extract( $clauses, EXTR_SKIP ); 2207 if ( is_array( $clauses ) ) { 2208 extract( $clauses, EXTR_SKIP ); 2209 } 2207 2210 unset( $clauses ); 2211 // prevent notices in case a filter removed clause variable(s) 2212 foreach ( $variables as $variable_name => $filter_name ) { 2213 if ( !isset( ${$variable_name} ) ) { 2214 $$variable_name = ''; 2215 } 2216 } 2208 2217 } 2209 2218 2210 2219 // Announce current selection parameters. For use by caching plugins. … … 2223 2232 2224 2233 if ( ! empty($groupby) ) 2225 2234 $groupby = 'GROUP BY ' . $groupby; 2226 if ( ! empty( $orderby ) )2235 if ( ! empty( $orderby ) ) 2227 2236 $orderby = 'ORDER BY ' . $orderby; 2228 2237 $found_rows = ''; 2229 if ( !$q['no_found_rows'] && ! empty($limits) )2238 if ( !$q['no_found_rows'] && ! empty( $limits ) ) 2230 2239 $found_rows = 'SQL_CALC_FOUND_ROWS'; 2231 2240 2232 2241 $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";