Ticket #10972: posts-only-sanitize-once-2.patch
File posts-only-sanitize-once-2.patch, 2.4 KB (added by , 15 years ago) |
---|
-
wp-includes/post.php
232 232 return $null; 233 233 } elseif ( is_object($post) && empty($post->filter) ) { 234 234 _get_post_ancestors($post); 235 wp_cache_add($post->ID, $post, 'posts');236 $_post = &$post;235 $_post = sanitize_post($post, 'raw'); 236 wp_cache_add($post->ID, $_post, 'posts'); 237 237 } else { 238 238 if ( is_object($post) ) 239 239 $post = $post->ID; … … 243 243 if ( ! $_post ) 244 244 return $null; 245 245 _get_post_ancestors($_post); 246 $_post = sanitize_post($_post, 'raw'); 246 247 wp_cache_add($_post->ID, $_post, 'posts'); 247 248 } 248 249 } 249 250 250 $_post = sanitize_post($_post, $filter); 251 if ($filter != 'raw') 252 $_post = sanitize_post($_post, $filter); 251 253 252 254 if ( $output == OBJECT ) { 253 255 return $_post; … … 817 819 */ 818 820 function sanitize_post($post, $context = 'display') { 819 821 if ( is_object($post) ) { 822 // Check if post already filtered for this context 823 if ( isset($post->filter) && $context == $post->filter ) 824 return $post; 820 825 if ( !isset($post->ID) ) 821 826 $post->ID = 0; 822 827 foreach ( array_keys(get_object_vars($post)) as $field ) 823 828 $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context); 824 829 $post->filter = $context; 825 830 } else { 831 // Check if post already filtered for this context 832 if ( isset($post['filter']) && $context == $post['filter'] ) 833 return $post; 826 834 if ( !isset($post['ID']) ) 827 835 $post['ID'] = 0; 828 836 foreach ( array_keys($post) as $field ) … … 2450 2458 return $pages; 2451 2459 } 2452 2460 2461 // Sanitize before caching so it'll only get done once 2462 $num_pages = count($pages); 2463 for ($i = 0; $i < $num_pages; $i++) { 2464 $pages[$i] = sanitize_post($pages[$i], 'raw'); 2465 } 2466 2453 2467 // Update cache. 2454 2468 update_page_cache($pages); 2455 2469 -
wp-includes/query.php
2360 2360 if ( !$q['suppress_filters'] ) 2361 2361 $this->posts = apply_filters('the_posts', $this->posts); 2362 2362 2363 // Sanitize before caching so it'll only get done once 2364 $num_posts = count($this->posts); 2365 for ($i = 0; $i < $num_posts; $i++) { 2366 $this->posts[$i] = sanitize_post($this->posts[$i], 'raw'); 2367 } 2368 2363 2369 update_post_caches($this->posts); 2364 2370 2365 2371 $this->post_count = count($this->posts);