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
This commit is contained in:
Ryan Boren 2012-11-27 19:42:38 +00:00
parent e2bc567095
commit b237423e72
2 changed files with 3 additions and 7 deletions

View File

@ -3196,13 +3196,7 @@ function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $a
$tags = array_unique( array_map( 'intval', $tags ) ); $tags = array_unique( array_map( 'intval', $tags ) );
} }
$r = wp_set_object_terms( $post_id, $tags, $taxonomy, $append ); return 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;
} }
/** /**

View File

@ -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 ); 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); do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
return $tt_ids; return $tt_ids;
} }