Ticket #19690: 19690.21.diff
File 19690.21.diff, 4.1 KB (added by , 13 years ago) |
---|
-
wp-includes/comment.php
1583 1583 $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) ); 1584 1584 $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) ); 1585 1585 1586 if ( 'page' == $post->post_type ) 1587 clean_page_cache( $post_id ); 1588 else 1589 clean_post_cache( $post_id ); 1586 clean_post_cache( $post_id, $post->post_type ); 1590 1587 1591 1588 do_action('wp_update_comment_count', $post_id, $new, $old); 1592 1589 do_action('edit_post', $post_id, $post); -
wp-includes/post.php
1361 1361 $post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db'); 1362 1362 $return = $wpdb->update($wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) ); 1363 1363 1364 if ( 'page' == $post_type ) 1365 clean_page_cache($post_id); 1366 else 1367 clean_post_cache($post_id); 1364 clean_post_cache($post_id, $post_type); 1368 1365 1369 1366 return $return; 1370 1367 } … … 2056 2053 $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); 2057 2054 do_action( 'deleted_post', $postid ); 2058 2055 2059 if ( 'page' == $post->post_type ) { 2060 clean_page_cache($postid); 2061 } else { 2062 clean_post_cache($postid); 2063 } 2056 clean_post_cache($postid, $post->post_type); 2064 2057 2065 2058 if ( is_post_type_hierarchical( $post->post_type ) ) { 2066 2059 foreach ( (array) $children as $child ) 2067 clean_post_cache( $child->ID );2060 clean_post_cache( $child->ID, $child->post_type ); 2068 2061 } 2069 2062 2070 2063 wp_clear_scheduled_hook('publish_future_post', array( $postid ) ); … … 2643 2636 2644 2637 $current_guid = get_post_field( 'guid', $post_ID ); 2645 2638 2646 if ( 'page' == $data['post_type'] ) 2647 clean_page_cache($post_ID); 2648 else 2649 clean_post_cache($post_ID); 2639 clean_post_cache($post_ID, $data['post_type']); 2650 2640 2651 2641 // Set GUID 2652 2642 if ( !$update && '' == $current_guid ) … … 3751 3741 if ( $file ) 3752 3742 update_attached_file( $post_ID, $file ); 3753 3743 3754 clean_post_cache($post_ID );3744 clean_post_cache($post_ID, $post_type); 3755 3745 3756 3746 if ( ! empty( $context ) ) 3757 3747 add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); … … 3864 3854 if ( ! empty($file) ) 3865 3855 @ unlink($file); 3866 3856 3867 clean_post_cache($post_id );3857 clean_post_cache($post_id, $post->post_type); 3868 3858 3869 3859 return $post; 3870 3860 } … … 4348 4338 * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any). 4349 4339 * 4350 4340 * @param int $id The Post ID in the cache to clean 4341 * @param string $post_type The post_type of the post. Defaults to "post" 4351 4342 */ 4352 function clean_post_cache($id ) {4343 function clean_post_cache($id, $post_type = 'post') { 4353 4344 global $_wp_suspend_cache_invalidation, $wpdb; 4354 4345 4355 4346 if ( !empty($_wp_suspend_cache_invalidation) ) … … 4360 4351 if ( 0 === $id ) 4361 4352 return; 4362 4353 4363 $post = get_post( $id );4364 4365 4354 wp_cache_delete($id, 'posts'); 4366 4355 wp_cache_delete($id, 'post_meta'); 4367 4356 4368 clean_object_term_cache( $id, $post ->post_type );4357 clean_object_term_cache( $id, $post_type ); 4369 4358 4370 4359 wp_cache_delete( 'wp_get_archives', 'general' ); 4371 4360 … … 4376 4365 // Loop detection 4377 4366 if ( $cid == $id ) 4378 4367 continue; 4379 clean_post_cache( $cid );4368 clean_post_cache( $cid, $cid->post_type ); 4380 4369 } 4381 4370 } 4382 4371 … … 4414 4403 * @param int $id Page ID to clean 4415 4404 */ 4416 4405 function clean_page_cache($id) { 4417 clean_post_cache($id );4406 clean_post_cache($id, 'page'); 4418 4407 4419 4408 wp_cache_delete( 'all_page_ids', 'posts' ); 4420 4409 wp_cache_delete( 'get_pages', 'posts' ); … … 4629 4618 * @param object $post Object type containing the post information 4630 4619 */ 4631 4620 function _save_post_hook($post_id, $post) { 4632 if ( $post->post_type == 'page' ) { 4633 clean_page_cache($post_id); 4634 } else { 4635 clean_post_cache($post_id); 4636 } 4621 clean_post_cache($post_id, $post->post_type); 4637 4622 } 4638 4623 4639 4624 /** … … 5361 5346 5362 5347 update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache ); 5363 5348 } 5364 } 5365 No newline at end of file 5349 }