mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Invalidate cache for child terms when parent term is deleted.
Props socki03. Fixes #29911. git-svn-id: https://develop.svn.wordpress.org/trunk@29945 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1006,6 +1006,33 @@ class Tests_Term extends WP_UnitTestCase {
|
||||
$this->assertTrue( in_array( $found['term_id'], $cached_children[ $t2 ] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29911
|
||||
*/
|
||||
public function test_wp_delete_term_should_invalidate_cache_for_child_terms() {
|
||||
register_taxonomy( 'wptests_tax', 'post', array(
|
||||
'hierarchical' => true,
|
||||
) );
|
||||
|
||||
$parent = $this->factory->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
|
||||
$child = $this->factory->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'parent' => $parent,
|
||||
'slug' => 'foo',
|
||||
) );
|
||||
|
||||
// Prime the cache.
|
||||
$child_term = get_term( $child, 'wptests_tax' );
|
||||
$this->assertSame( $parent, $child_term->parent );
|
||||
|
||||
wp_delete_term( $parent, 'wptests_tax' );
|
||||
$child_term = get_term( $child, 'wptests_tax' );
|
||||
$this->assertSame( 0, $child_term->parent );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 5381
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user