Changeset 30108
- Timestamp:
- 10/30/2014 02:49:51 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r30107 r30108 1296 1296 if ( !$term = (int) $term ) 1297 1297 return null; 1298 if ( ! $_term = wp_cache_get( $term, $taxonomy) ) {1298 if ( ! $_term = wp_cache_get( $term, $taxonomy . ':terms:' . $incrementor ) ) { 1299 1299 $_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term) ); 1300 1300 if ( ! $_term ) -
trunk/tests/phpunit/tests/term/cache.php
r30080 r30108 109 109 $this->assertEquals( $initial, $wpdb->num_queries ); 110 110 111 $this->assertEquals( $term, wp_cache_get( $term_id, 'post_tag ') );111 $this->assertEquals( $term, wp_cache_get( $term_id, 'post_tag:terms:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 112 112 113 113 $this->assertEquals( get_term( $term_id, 'post_tag' ), $term ); … … 129 129 $this->assertEquals( $initial, $wpdb->num_queries ); 130 130 131 $this->assertEquals( $term, wp_cache_get( $term_id, 'post_tag ') );131 $this->assertEquals( $term, wp_cache_get( $term_id, 'post_tag:terms:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 132 132 133 133 wp_update_term( $term_id, 'post_tag', array( 'name' => 'Taco' ) ); … … 184 184 $name = 'Taco'; 185 185 $taxonomy = 'post_tag'; 186 $cache_key_slug = 'slug:' .$slug;187 $cache_key_name = 'name:' . md5( $name );186 $cache_key_slug = $slug; 187 $cache_key_name = $name; 188 188 189 189 $term_id = $this->factory->term->create( array( 'slug' => $slug, 'name' => $name, 'taxonomy' => $taxonomy ) ); 190 190 191 191 $last_changed = wp_cache_get( 'last_changed', 'terms' ); 192 $group = $taxonomy . ':' . $last_changed;193 192 194 193 $term = get_term_by( 'slug', $slug, $taxonomy ); 195 194 196 195 // Verify the term is cached by ID, slug and name 197 $this->assertEquals( $term, wp_cache_get( $term_id, $taxonomy ) );198 $this->assert Equals( $term_id, wp_cache_get( $cache_key_slug, $group) );199 $this->assert Equals( $term_id, wp_cache_get( $cache_key_name, $group) );196 $this->assertEquals( $term, wp_cache_get( $term_id, $taxonomy . ':terms:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 197 $this->assertSame( $term_id, wp_cache_get( $cache_key_slug, $taxonomy . ':slugs:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 198 $this->assertSame( $term_id, wp_cache_get( $cache_key_name, $taxonomy . ':names:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 200 199 201 200 wp_suspend_cache_invalidation(); … … 203 202 204 203 // Verify that the cached value still matches the correct value 205 $this->assertEquals( $term, wp_cache_get( $term_id, $taxonomy ) );206 $this->assert Equals( $term_id, wp_cache_get( $cache_key_slug, $group) );207 $this->assert Equals( $term_id, wp_cache_get( $cache_key_name, $group) );204 $this->assertEquals( $term, wp_cache_get( $term_id, $taxonomy . ':terms:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 205 $this->assertSame( $term_id, wp_cache_get( $cache_key_slug, $taxonomy . ':slugs:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 206 $this->assertSame( $term_id, wp_cache_get( $cache_key_name, $taxonomy . ':names:' . wp_cache_get( 'last_changed', 'terms' ) ) ); 208 207 209 208 // Verify that last changed has not been updated as part of an invalidation routine 210 $this->assert Equals( $last_changed, wp_get_last_changed('terms' ) );209 $this->assertSame( $last_changed, wp_cache_get( 'last_changed', 'terms' ) ); 211 210 } 212 211 }
Note: See TracChangeset
for help on using the changeset viewer.