From b237423e7252961c09c28b8b23a6eeb822c09a70 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 27 Nov 2012 19:42:38 +0000 Subject: [PATCH] Clear the object term relationships cache in wp_set_object_terms() rather than wp_set_post_terms(). This should be done lower in the stack than wp_set_post_terms(). Props batmoo fixes #22560 git-svn-id: http://core.svn.wordpress.org/trunk@22878 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 8 +------- wp-includes/taxonomy.php | 2 ++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 37106b3d29..55527fea85 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3196,13 +3196,7 @@ function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $a $tags = array_unique( array_map( 'intval', $tags ) ); } - $r = wp_set_object_terms( $post_id, $tags, $taxonomy, $append ); - if ( is_wp_error( $r ) ) - return $r; - - wp_cache_delete( $post_id, $taxonomy . '_relationships' ); - - return $r; + return wp_set_object_terms( $post_id, $tags, $taxonomy, $append ); } /** diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 1760df24e2..1932bab383 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2238,6 +2238,8 @@ function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) { return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error ); } + wp_cache_delete( $object_id, $taxonomy . '_relationships' ); + do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); return $tt_ids; }