Make WordPress Core


Ignore:
Timestamp:
11/14/2014 09:52:23 PM (10 years ago)
Author:
boonebgorges
Message:

Flush cache for newly created term in _split_shared_term().

The term itself does not have any cached values yet, but in some cases the new
term's taxonomy may need its cached hierarchy to be refreshed as a result of
the term splitting.

Props jorbin.
See #30335.

File:
1 edited

Legend:

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

    r30344 r30347  
    9090        $this->assertEquals( $this->tt_ids['t2_child'], $children[0]->term_taxonomy_id );
    9191    }
     92
     93    /**
     94     * @ticket 30335
     95     */
     96    public function test_should_rebuild_split_term_taxonomy_hierarchy() {
     97        global $wpdb;
     98
     99        register_taxonomy( 'wptests_tax_3', 'post' );
     100        register_taxonomy( 'wptests_tax_4', 'post', array(
     101            'hierarchical' => true,
     102        ) );
     103
     104        $t1 = wp_insert_term( 'Foo1', 'wptests_tax_3' );
     105        $t2 = wp_insert_term( 'Foo1 Parent', 'wptests_tax_4' );
     106        $t3 = wp_insert_term( 'Foo1', 'wptests_tax_4', array(
     107            'parent' => $t2['term_id'],
     108        ) );
     109
     110        // Manually modify because split terms shouldn't naturally occur.
     111        $wpdb->update( $wpdb->term_taxonomy,
     112            array( 'term_id' => $t1['term_id'] ),
     113            array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ),
     114            array( '%d' ),
     115            array( '%d' )
     116        );
     117        $th = _get_term_hierarchy( 'wptests_tax_4' );
     118
     119        $new_term_id = _split_shared_term( $t1['term_id'], $t3['term_taxonomy_id'] );
     120
     121        $t2_children = get_term_children( $t2['term_id'], 'wptests_tax_4' );
     122        $this->assertEquals( array( $new_term_id ), $t2_children );
     123    }
    92124}
Note: See TracChangeset for help on using the changeset viewer.