Make WordPress Core


Ignore:
Timestamp:
02/11/2014 04:49:11 PM (11 years ago)
Author:
wonderboymusic
Message:

Partially revert [27101], [27102], [27141], and [27142]. Those commits introduced new functions to sync up cache invalidation events. The current commit alters existing internals.

"The cache invalidation with static was introduced in r9102 with version 2.7. Multisite wasn't in core back then, so something like switch_to_blog() wasn't a concern, but now it breaks if you switch the blog in between calls to clean_term_cache."

This solution is simpler. All unit tests pass. Removes unnecessary tests linked to removed functions.

Props kovshenin.
Fixes #14485, #22526.

File:
1 edited

Legend:

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

    r27142 r27163  
    3333     * @ticket 22526
    3434     */
    35     function test_get_taxonomy_last_changed() {
    36         $last_changed = get_taxonomy_last_changed( 'category' );
    37         $key = 'category_last_changed';
    38         $last_changed_cache = wp_cache_get( $key, 'terms' );
    39         $this->assertEquals( $last_changed, $last_changed_cache );
    40         wp_cache_delete( $key, 'terms' );
    41         $this->assertEquals( $last_changed, $last_changed_cache );
    42         $last_changed = get_taxonomy_last_changed( 'category' );
    43         $this->assertNotEquals( $last_changed, $last_changed_cache );
    44 
    45         $last_changed2 = get_taxonomy_last_changed( 'category' );
    46         $this->factory->category->create();
    47         $last_changed3 = get_taxonomy_last_changed( 'category' );
    48         $this->assertNotEquals( $last_changed2, $last_changed3 );
    49     }
    50 
    51     /**
    52      * @ticket 22526
    53      */
    54     function test_set_taxonomy_last_changed() {
    55         $last_changed1 = set_taxonomy_last_changed( 'category' );
    56         $last_changed2 = set_taxonomy_last_changed( 'category' );
    57         $this->assertNotEquals( $last_changed1, $last_changed2 );
    58 
    59         $last_changed3 = set_taxonomy_last_changed( 'category' );
    60         $last_changed4 = get_taxonomy_last_changed( 'category' );
    61         $this->assertEquals( $last_changed3, $last_changed4 );
    62     }
    63 
    64     /**
    65      * @ticket 22526
    66      */
    67     function test_post_taxonomy_is_fresh() {
    68         $post_id = $this->factory->post->create();
    69         $term_id = $this->factory->category->create( array( 'name' => 'Foo' ) );
    70         wp_set_post_categories( $post_id, $term_id );
    71 
    72         $this->assertFalse( post_taxonomy_is_fresh( $post_id, 'category' ) );
    73         $this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );
    74         $this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );
    75 
    76         wp_update_term( $term_id, 'category', array( 'name' => 'Bar' ) );
    77 
    78         $this->assertFalse( post_taxonomy_is_fresh( $post_id, 'category' ) );
    79         get_the_category( $post_id );
    80         $this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );
    81     }
    82 
    83     /**
    84      * @ticket 22526
    85      */
    8635    function test_category_name_change() {
    8736        $term = $this->factory->category->create_and_get( array( 'name' => 'Foo' ) );
     
    9847    }
    9948
     49    /**
     50     * @ticket 14485
     51     */
    10052    function test_hierachy_invalidation() {
    10153        $tax = 'burrito';
     
    12779            $terms = get_terms( $tax, array( 'hide_empty' => false ) );
    12880            $this->assertEquals( $i, count( $terms ) );
    129             if ( 1 < $i ) {
     81            if ( $i > 1 ) {
    13082                $hierarchy = _get_term_hierarchy( $tax );
    13183                $this->assertNotEmpty( $hierarchy );
Note: See TracChangeset for help on using the changeset viewer.