WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#11744 closed defect (bug) (fixed)

the global-posts bucket potentially contains garbage

Reported by: Denis-de-Bernardy Owned by: ryan
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Cache API Keywords: has-patch
Focuses: multisite Cc:

Description

the newly introduced get_blog_post() function potentially contains garbage and is insufficiently cleaned up. it uses the following logic:

wp_cache_get("$blog_id-$post_id", "global-posts");
if false then
  select post regardless of status (can be trashed, draft, pending...)
  wp_cache_add() the thing in memcache

the issue is the cleanup:

function clear_global_post_cache( $post_id ) {
	global $wpdb;

	wp_cache_delete( $wpdb->blogid . '-' . $post_id, 'global-posts' );
}
add_action( 'publish_post', 'clear_global_post_cache' );
add_action( 'delete_post', 'clear_global_post_cache' );

if a published post gets turned back to pending status, for instance, the global-posts bucket will still contain the cached post. we should use the save_post hook instead.

Attachments (1)

11744.diff (526 bytes) - added by Denis-de-Bernardy 4 years ago.

Download all attachments as: .zip

Change History (3)

Denis-de-Bernardy4 years ago

comment:1 nacin4 years ago

  • Keywords multisite added

comment:2 ryan4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12768]) Merge clear_global_post_cache() into clean_post_cache(). fixes #11744

Note: See TracTickets for help on using tickets.