Ticket #20486: 20486.3.diff
| File 20486.3.diff, 5.4 KB (added by duck_, 13 months ago) |
|---|
-
wp-includes/comment.php
1579 1579 $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) ); 1580 1580 $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) ); 1581 1581 1582 clean_post_cache( $post _id, $post->post_type);1582 clean_post_cache( $post ); 1583 1583 1584 1584 do_action('wp_update_comment_count', $post_id, $new, $old); 1585 1585 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 clean_post_cache( $post_id , $post_type);1364 clean_post_cache( $post_id ); 1365 1365 1366 1366 return $return; 1367 1367 } … … 2045 2045 $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); 2046 2046 do_action( 'deleted_post', $postid ); 2047 2047 2048 clean_post_cache( $post id, $post->post_type);2048 clean_post_cache( $post ); 2049 2049 2050 2050 if ( is_post_type_hierarchical( $post->post_type ) ) { 2051 2051 foreach ( (array) $children as $child ) 2052 clean_post_cache( $child ->ID, $child->post_type);2052 clean_post_cache( $child ); 2053 2053 } 2054 2054 2055 2055 wp_clear_scheduled_hook('publish_future_post', array( $postid ) ); … … 2628 2628 2629 2629 $current_guid = get_post_field( 'guid', $post_ID ); 2630 2630 2631 clean_post_cache( $post_ID , $data['post_type']);2631 clean_post_cache( $post_ID ); 2632 2632 2633 2633 // Set GUID 2634 2634 if ( !$update && '' == $current_guid ) … … 3733 3733 if ( $file ) 3734 3734 update_attached_file( $post_ID, $file ); 3735 3735 3736 clean_post_cache( $post_ID , $post_type);3736 clean_post_cache( $post_ID ); 3737 3737 3738 3738 if ( ! empty( $context ) ) 3739 3739 add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); … … 3838 3838 if ( ! empty($file) ) 3839 3839 @ unlink($file); 3840 3840 3841 clean_post_cache( $post _id, $post->post_type);3841 clean_post_cache( $post ); 3842 3842 3843 3843 return $post; 3844 3844 } … … 4319 4319 * 4320 4320 * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any). 4321 4321 * 4322 * @param int $id The Post ID in the cache to clean 4323 * @param string $post_type The post_type of the post. Defaults to "post" 4322 * @param object|int $post The post object or ID to remove from the cache 4324 4323 */ 4325 function clean_post_cache( $id, $post_type = 'post') {4324 function clean_post_cache( $post ) { 4326 4325 global $_wp_suspend_cache_invalidation, $wpdb; 4327 4326 4328 4327 if ( ! empty( $_wp_suspend_cache_invalidation ) ) 4329 4328 return; 4330 4329 4331 $id = (int) $id; 4332 4333 if ( 0 === $id ) 4330 $post = get_post( $post ); 4331 if ( empty( $post ) ) 4334 4332 return; 4335 4333 4336 wp_cache_delete( $id, 'posts');4337 wp_cache_delete( $id, 'post_meta');4334 wp_cache_delete( $post->ID, 'posts' ); 4335 wp_cache_delete( $post->ID, 'post_meta' ); 4338 4336 4339 clean_object_term_cache( $ id, $post_type );4337 clean_object_term_cache( $post->ID, $post->post_type ); 4340 4338 4341 4339 wp_cache_delete( 'wp_get_archives', 'general' ); 4342 4340 4343 do_action( 'clean_post_cache', $ id, $post_type);4341 do_action( 'clean_post_cache', $post->ID, $post ); 4344 4342 4345 if ( 'page' == $post _type ) {4343 if ( 'page' == $post->post_type ) { 4346 4344 wp_cache_delete( 'all_page_ids', 'posts' ); 4347 4345 wp_cache_delete( 'get_pages', 'posts' ); 4348 do_action( 'clean_page_cache', $ id);4346 do_action( 'clean_page_cache', $post->ID ); 4349 4347 } 4350 4348 4351 if ( $children = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_type FROM $wpdb->posts WHERE post_parent = %d", $ id) ) ) {4352 foreach ( $children as $c id ) {4349 if ( $children = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_type FROM $wpdb->posts WHERE post_parent = %d", $post->ID) ) ) { 4350 foreach ( $children as $child ) { 4353 4351 // Loop detection 4354 if ( $c id->ID == $id)4352 if ( $child->ID == $post->ID ) 4355 4353 continue; 4356 clean_post_cache( $c id->ID, $cid->post_type);4354 clean_post_cache( $child ); 4357 4355 } 4358 4356 } 4359 4357 4360 4358 if ( is_multisite() ) 4361 wp_cache_delete( $wpdb->blogid . '-' . $ id, 'global-posts' );4359 wp_cache_delete( $wpdb->blogid . '-' . $post->ID, 'global-posts' ); 4362 4360 } 4363 4361 4364 4362 /** … … 4563 4561 * @param int $post_id The ID in the database table for the $post 4564 4562 * @param object $post Object type containing the post information 4565 4563 */ 4566 function _save_post_hook( $post_id, $post) {4567 clean_post_cache( $post_id, $post->post_type);4564 function _save_post_hook( $post_id, $post ) { 4565 clean_post_cache( $post ); 4568 4566 } 4569 4567 4570 4568 /** -
wp-includes/deprecated.php
3150 3150 function clean_page_cache( $id ) { 3151 3151 _deprecated_function( __FUNCTION__, 3.4, 'clean_post_cache()' ); 3152 3152 3153 clean_post_cache( $id , 'page');3153 clean_post_cache( $id ); 3154 3154 } -
wp-admin/includes/class-wp-posts-list-table.php
360 360 if ( $page->post_parent == $page->ID ) { 361 361 $page->post_parent = 0; 362 362 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); 363 clean_post_cache( $page ->ID, $page->post_type);363 clean_post_cache( $page ); 364 364 } 365 365 366 366 if ( 0 == $page->post_parent )
