Bust object term cache in wp_remove_object_terms()
.
Props tszming. Fixes #34338. git-svn-id: https://develop.svn.wordpress.org/trunk@35268 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
063d42a801
commit
990eebf373
@ -2908,6 +2908,8 @@ function wp_remove_object_terms( $object_id, $terms, $taxonomy ) {
|
||||
do_action( 'delete_term_relationships', $object_id, $tt_ids );
|
||||
$deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) );
|
||||
|
||||
wp_cache_delete( $object_id, $taxonomy . '_relationships' );
|
||||
|
||||
/**
|
||||
* Fires immediately after an object-term relationship is deleted.
|
||||
*
|
||||
|
24
tests/phpunit/tests/term/wpRemoveObjectTerms.php
Normal file
24
tests/phpunit/tests/term/wpRemoveObjectTerms.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group taxonomy
|
||||
*/
|
||||
class Tests_Term_WpRemoveObjectTerms extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34338
|
||||
*/
|
||||
public function test_removal_should_delete_object_relationship_cache() {
|
||||
register_taxonomy( 'wptests_tax', 'post' );
|
||||
$p = self::factory()->post->create();
|
||||
$t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
|
||||
|
||||
wp_set_object_terms( $p, $t, 'wptests_tax' );
|
||||
|
||||
// Pollute the cache.
|
||||
get_the_terms( $p, 'wptests_tax' );
|
||||
|
||||
wp_remove_object_terms( $p, $t, 'wptests_tax' );
|
||||
|
||||
$this->assertFalse( get_the_terms( $p, 'wptests_tax' ) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user