Make WordPress Core

Ticket #25711: 25711.diff

File 25711.diff, 1.8 KB (added by dd32, 12 years ago)
  • tests/phpunit/tests/term/cache.php

     
     1<?php
     2
     3/**
     4 * @group taxonomy
     5 */
     6class Tests_Term_Cache extends WP_UnitTestCase {
     7        function setUp() {
     8                parent::setUp();
     9
     10                wp_cache_delete( 'last_changed', 'terms' );
     11        }
     12
     13        /**
     14         * @ticket 25711
     15         */
     16        function test_category_children_cache() {
     17                // Test with only one Parent => Child
     18                $term_id1 = $this->factory->category->create();
     19                $term_id1_child = $this->factory->category->create( array( 'parent' => $term_id1 ) );
     20                $hierarchy = _get_term_hierarchy( 'category' );
     21
     22                $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy );
     23
     24                // Add another Parent => Child
     25                $term_id2 = $this->factory->category->create();
     26                $term_id2_child = $this->factory->category->create( array( 'parent' => $term_id2 ) );
     27                $hierarchy = _get_term_hierarchy( 'category' );
     28
     29                $this->assertEquals( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ) ), $hierarchy );
     30
     31        }
     32}
     33 No newline at end of file
  • src/wp-includes/taxonomy.php

     
    27412741 */
    27422742function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {
    27432743        global $wpdb;
    2744         static $cleaned = array();
    27452744
    27462745        if ( !is_array($ids) )
    27472746                $ids = array($ids);
     
    27692768        }
    27702769
    27712770        foreach ( $taxonomies as $taxonomy ) {
    2772                 if ( isset($cleaned[$taxonomy]) )
    2773                         continue;
    2774                 $cleaned[$taxonomy] = true;
    27752771
    27762772                if ( $clean_taxonomy ) {
    27772773                        wp_cache_delete('all_ids', $taxonomy);