From 285247786ed7bbeb8e7d6371408195b153451eb4 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 11 Jan 2012 21:26:18 +0000 Subject: [PATCH] Use wp_cache_add() instead of wp_cache_set() when priming the object term cache in update_object_term_cache(). Pass the real post_type to clean_object_term_cache() instead of hard-coding post. Call clean_object_term_cache() from clean_bookmark_cache(). Props leewillis77. fixes #19690 git-svn-id: https://develop.svn.wordpress.org/trunk@19729 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/bookmark.php | 3 ++- wp-includes/post.php | 4 +++- wp-includes/taxonomy.php | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index 0c0c4c7819..8248e3a64f 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -375,7 +375,8 @@ function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { * @since 2.7.0 * @uses wp_cache_delete() Deletes the contents of 'get_bookmarks' */ -function clean_bookmark_cache($bookmark_id) { +function clean_bookmark_cache( $bookmark_id ) { wp_cache_delete( $bookmark_id, 'bookmark' ); wp_cache_delete( 'get_bookmarks', 'bookmark' ); + clean_object_term_cache( $bookmark_id, 'link'); } diff --git a/wp-includes/post.php b/wp-includes/post.php index 289f55cc3f..b8c229a0d9 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4330,10 +4330,12 @@ function clean_post_cache($id) { if ( 0 === $id ) return; + $post = get_post( $id ); + wp_cache_delete($id, 'posts'); wp_cache_delete($id, 'post_meta'); - clean_object_term_cache($id, 'post'); + clean_object_term_cache( $id, $post->post_type ); wp_cache_delete( 'wp_get_archives', 'general' ); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 974943f9cd..8fabcd3751 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2657,7 +2657,7 @@ function update_object_term_cache($object_ids, $object_type) { $object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term; foreach ( $ids as $id ) { - foreach ( $taxonomies as $taxonomy ) { + foreach ( $taxonomies as $taxonomy ) { if ( ! isset($object_terms[$id][$taxonomy]) ) { if ( !isset($object_terms[$id]) ) $object_terms[$id] = array(); @@ -2668,7 +2668,7 @@ function update_object_term_cache($object_ids, $object_type) { foreach ( $object_terms as $id => $value ) { foreach ( $value as $taxonomy => $terms ) { - wp_cache_set($id, $terms, "{$taxonomy}_relationships"); + wp_cache_add( $id, $terms, "{$taxonomy}_relationships" ); } } }