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.



git-svn-id: https://develop.svn.wordpress.org/trunk@27163 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-02-11 16:49:11 +00:00
parent 05b87717c8
commit 2e9d155703
2 changed files with 11 additions and 159 deletions

View File

@@ -29,57 +29,6 @@ class Tests_Term_Cache extends WP_UnitTestCase {
$this->assertEquals( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ) ), $hierarchy );
}
/**
* @ticket 22526
*/
function test_get_taxonomy_last_changed() {
$last_changed = get_taxonomy_last_changed( 'category' );
$key = 'category_last_changed';
$last_changed_cache = wp_cache_get( $key, 'terms' );
$this->assertEquals( $last_changed, $last_changed_cache );
wp_cache_delete( $key, 'terms' );
$this->assertEquals( $last_changed, $last_changed_cache );
$last_changed = get_taxonomy_last_changed( 'category' );
$this->assertNotEquals( $last_changed, $last_changed_cache );
$last_changed2 = get_taxonomy_last_changed( 'category' );
$this->factory->category->create();
$last_changed3 = get_taxonomy_last_changed( 'category' );
$this->assertNotEquals( $last_changed2, $last_changed3 );
}
/**
* @ticket 22526
*/
function test_set_taxonomy_last_changed() {
$last_changed1 = set_taxonomy_last_changed( 'category' );
$last_changed2 = set_taxonomy_last_changed( 'category' );
$this->assertNotEquals( $last_changed1, $last_changed2 );
$last_changed3 = set_taxonomy_last_changed( 'category' );
$last_changed4 = get_taxonomy_last_changed( 'category' );
$this->assertEquals( $last_changed3, $last_changed4 );
}
/**
* @ticket 22526
*/
function test_post_taxonomy_is_fresh() {
$post_id = $this->factory->post->create();
$term_id = $this->factory->category->create( array( 'name' => 'Foo' ) );
wp_set_post_categories( $post_id, $term_id );
$this->assertFalse( post_taxonomy_is_fresh( $post_id, 'category' ) );
$this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );
$this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );
wp_update_term( $term_id, 'category', array( 'name' => 'Bar' ) );
$this->assertFalse( post_taxonomy_is_fresh( $post_id, 'category' ) );
get_the_category( $post_id );
$this->assertTrue( post_taxonomy_is_fresh( $post_id, 'category' ) );
}
/**
* @ticket 22526
*/
@@ -97,6 +46,9 @@ class Tests_Term_Cache extends WP_UnitTestCase {
$this->assertNotEquals( $term->name, reset( $cats2 )->name );
}
/**
* @ticket 14485
*/
function test_hierachy_invalidation() {
$tax = 'burrito';
register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
@@ -126,7 +78,7 @@ class Tests_Term_Cache extends WP_UnitTestCase {
$terms = get_terms( $tax, array( 'hide_empty' => false ) );
$this->assertEquals( $i, count( $terms ) );
if ( 1 < $i ) {
if ( $i > 1 ) {
$hierarchy = _get_term_hierarchy( $tax );
$this->assertNotEmpty( $hierarchy );
$this->assertEquals( $children, count( $hierarchy, COUNT_RECURSIVE ) - count( $hierarchy ) );