Changeset 40354 for branches/4.7
- Timestamp:
- 03/30/2017 04:55:32 PM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/src/wp-includes/taxonomy.php
r40291 r40354 2313 2313 2314 2314 wp_cache_delete( $object_id, $taxonomy . '_relationships' ); 2315 wp_cache_delete( 'last_changed', 'terms' ); 2315 2316 2316 2317 /** … … 2407 2408 2408 2409 wp_cache_delete( $object_id, $taxonomy . '_relationships' ); 2410 wp_cache_delete( 'last_changed', 'terms' ); 2409 2411 2410 2412 /** -
branches/4.7/tests/phpunit/tests/term/getTheTerms.php
r39174 r40354 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.