WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/17/2014 08:58:48 PM (7 years ago)
Author:
boonebgorges
Message:

Invalidate cache for child terms when parent term is deleted.

Props socki03.
Fixes #29911.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term.php

    r29875 r29945  
    10081008
    10091009    /**
     1010     * @ticket 29911
     1011     */
     1012    public function test_wp_delete_term_should_invalidate_cache_for_child_terms() {
     1013        register_taxonomy( 'wptests_tax', 'post', array(
     1014            'hierarchical' => true,
     1015        ) );
     1016
     1017        $parent = $this->factory->term->create( array(
     1018            'taxonomy' => 'wptests_tax',
     1019        ) );
     1020
     1021        $child = $this->factory->term->create( array(
     1022            'taxonomy' => 'wptests_tax',
     1023            'parent' => $parent,
     1024            'slug' => 'foo',
     1025        ) );
     1026
     1027        // Prime the cache.
     1028        $child_term = get_term( $child, 'wptests_tax' );
     1029        $this->assertSame( $parent, $child_term->parent );
     1030
     1031        wp_delete_term( $parent, 'wptests_tax' );
     1032        $child_term = get_term( $child, 'wptests_tax' );
     1033        $this->assertSame( 0, $child_term->parent );
     1034    }
     1035
     1036    /**
    10101037     * @ticket 5381
    10111038     */
Note: See TracChangeset for help on using the changeset viewer.