- Timestamp:
- 03/30/2017 04:49:47 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r40298 r40353 2283 2283 2284 2284 wp_cache_delete( $object_id, $taxonomy . '_relationships' ); 2285 wp_cache_delete( 'last_changed', 'terms' ); 2285 2286 2286 2287 /** … … 2377 2378 2378 2379 wp_cache_delete( $object_id, $taxonomy . '_relationships' ); 2380 wp_cache_delete( 'last_changed', 'terms' ); 2379 2381 2380 2382 /** -
trunk/tests/phpunit/tests/term/getTheTerms.php
r39174 r40353 192 192 193 193 } 194 195 /** 196 * @ticket 40306 197 */ 198 public function test_term_cache_should_be_invalidated_on_set_object_terms() { 199 register_taxonomy( 'wptests_tax', 'post' ); 200 201 // Temporarily disable term counting, which performs its own cache invalidation. 202 wp_defer_term_counting( true ); 203 204 // Create Test Category. 205 $term_id = self::factory()->term->create( array( 206 'taxonomy' => 'wptests_tax', 207 ) ); 208 209 $post_id = self::factory()->post->create(); 210 211 // Prime cache. 212 get_the_terms( $post_id, 'wptests_tax' ); 213 214 wp_set_object_terms( $post_id, $term_id, 'wptests_tax' ); 215 216 $terms = get_the_terms( $post_id, 'wptests_tax' ); 217 218 // Re-activate term counting so this doesn't affect other tests. 219 wp_defer_term_counting( false ); 220 221 $this->assertTrue( is_array( $terms ) ); 222 $this->assertSame( array( $term_id ), wp_list_pluck( $terms, 'term_id' ) ); 223 } 224 225 /** 226 * @ticket 40306 227 */ 228 public function test_term_cache_should_be_invalidated_on_remove_object_terms() { 229 register_taxonomy( 'wptests_tax', 'post' ); 230 231 // Create Test Category. 232 $term_ids = self::factory()->term->create_many( 2, array( 233 'taxonomy' => 'wptests_tax', 234 ) ); 235 236 $post_id = self::factory()->post->create(); 237 238 wp_set_object_terms( $post_id, $term_ids, 'wptests_tax' ); 239 240 // Prime cache. 241 get_the_terms( $post_id, 'wptests_tax' ); 242 243 // Temporarily disable term counting, which performs its own cache invalidation. 244 wp_defer_term_counting( true ); 245 246 wp_remove_object_terms( $post_id, $term_ids[0], 'wptests_tax' ); 247 248 $terms = get_the_terms( $post_id, 'wptests_tax' ); 249 250 // Re-activate term counting so this doesn't affect other tests. 251 wp_defer_term_counting( false ); 252 253 $this->assertTrue( is_array( $terms ) ); 254 $this->assertSame( array( $term_ids[1] ), wp_list_pluck( $terms, 'term_id' ) ); 255 } 194 256 }
Note: See TracChangeset
for help on using the changeset viewer.