Ticket #18822: 18822.alt.2.diff

File 18822.alt.2.diff, 819 bytes (added by scribu, 20 months ago)
Line 
1diff --git wp-includes/query.php wp-includes/query.php
2index f47a860a..b7066d3 100644
3--- wp-includes/query.php
4+++ wp-includes/query.php
5@@ -2745,13 +2745,14 @@ class WP_Query {
6 
7                $this->post_count = count($this->posts);
8 
9-               // Sanitize before caching so it'll only get done once
10-               for ( $i = 0; $i < $this->post_count; $i++ ) {
11-                       $this->posts[$i] = sanitize_post($this->posts[$i], 'raw');
12-               }
13+               if ( $q['cache_results'] ) {
14+                       // Sanitize before caching so it'll only get done once
15+                       foreach ( $this->posts as $i => $post ) {
16+                               $this->posts[$i] = sanitize_post( $post, 'raw' );
17+                       }
18 
19-               if ( $q['cache_results'] )
20                        update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
21+               }
22 
23                if ( $this->post_count > 0 ) {
24                        $this->post = $this->posts[0];