mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-20 19:56:49 +01:00
More bonkers comment cache cleanup: toggle wp_defer_comment_counting() in wp_insert_post() and wp_insert_attachment(). Move the cache deletion in wp_update_comment_count_now() to before the get_post() call, so that the caches get deleted even if the post has already been deleted and the function returns early.
See #33875. Built from https://develop.svn.wordpress.org/trunk@34158 git-svn-id: http://core.svn.wordpress.org/trunk@34126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8479ff90bc
commit
31c2bfd69d
|
|
@ -1907,6 +1907,10 @@ function wp_update_comment_count_now($post_id) {
|
|||
$post_id = (int) $post_id;
|
||||
if ( !$post_id )
|
||||
return false;
|
||||
|
||||
wp_cache_delete( 'comments-0', 'counts' );
|
||||
wp_cache_delete( "comments-{$post_id}", 'counts' );
|
||||
|
||||
if ( !$post = get_post($post_id) )
|
||||
return false;
|
||||
|
||||
|
|
@ -1916,9 +1920,6 @@ function wp_update_comment_count_now($post_id) {
|
|||
|
||||
clean_post_cache( $post );
|
||||
|
||||
wp_cache_delete( 'comments-0', 'counts' );
|
||||
wp_cache_delete( "comments-{$post_id}", 'counts' );
|
||||
|
||||
/**
|
||||
* Fires immediately after a post's comment count is updated in the database.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1394,7 +1394,7 @@ function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
|
|||
}
|
||||
$labels = array_merge( $defaults, $object->labels );
|
||||
$object->labels = (object) $object->labels;
|
||||
|
||||
|
||||
return (object) $labels;
|
||||
}
|
||||
|
||||
|
|
@ -2370,9 +2370,14 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
|
|||
// Point all attachments to this post up one level.
|
||||
$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
|
||||
|
||||
wp_defer_comment_counting( true );
|
||||
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
|
||||
foreach ( $comment_ids as $comment_id )
|
||||
foreach ( $comment_ids as $comment_id ) {
|
||||
wp_delete_comment( $comment_id, true );
|
||||
}
|
||||
|
||||
wp_defer_comment_counting( false );
|
||||
|
||||
$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
|
||||
foreach ( $post_meta_ids as $mid )
|
||||
|
|
@ -4637,9 +4642,14 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
|||
// Delete all for any posts.
|
||||
delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );
|
||||
|
||||
wp_defer_comment_counting( true );
|
||||
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
|
||||
foreach ( $comment_ids as $comment_id )
|
||||
foreach ( $comment_ids as $comment_id ) {
|
||||
wp_delete_comment( $comment_id, true );
|
||||
}
|
||||
|
||||
wp_defer_comment_counting( false );
|
||||
|
||||
$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
|
||||
foreach ( $post_meta_ids as $mid )
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34136';
|
||||
$wp_version = '4.4-alpha-34158';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user