[wp-trac] [WordPress Trac] #20447: wp_delete_post( int, $user_id ) does not flush post caches

WordPress Trac wp-trac at lists.automattic.com
Sun Apr 15 11:19:26 UTC 2012


#20447: wp_delete_post( int, $user_id ) does not flush post caches
--------------------------+-----------------------------
 Reporter:  joehoyle      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Cache         |    Version:  3.4
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Calling `wp_delete_post( 2456, 1 )` does not flush the caches for the re-
 assigned posts. For example:

 {{{
 // assuming post 123 has an author of 2
 $post = get_post( 123 );

 wp_delete_user( $post->post_author, 1 );

 $post = get_post( 123 );
 $post->post_author; // this is "2", should be "1"
 }}}

 This is because `clean_post_cache` is not called on the reassigned posts
 (see http://core.trac.wordpress.org/browser/trunk/wp-
 admin/includes/user.php#L259).

 The best way around this I can see is get the post IDs and called
 wp_update_post() to let code hook in to update stuff where necessary. If
 performance is an issue (s wp_update_post can be slow), then I think it
 should at least get all the post IDs and call `clean_post_cache` on them.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20447>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list