Skip to content

Commit d42d2c3

Browse files
author
boonebgorges
committed
Don't clear object relationship caches on term update.
Since [37573], object relationship caches (`{$taxonomy}_relationships`) contain term IDs rather than term objects. See #36814. As such, it's no longer necessary to clear these caches when a term is updated; none of the data that's changed on update (name, description, count, etc) is stored in the relationship cache. Fixes #36251. git-svn-id: https://develop.svn.wordpress.org/trunk@37593 602fd350-edb4-49c9-b593-d223f7449a82
1 parent bb2d5a3 commit d42d2c3

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

src/wp-includes/taxonomy.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,13 +2948,6 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
29482948
*/
29492949
do_action( 'edited_term_taxonomy', $tt_id, $taxonomy );
29502950

2951-
// Clean the relationship caches for all object types using this term.
2952-
$objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
2953-
$tax_object = get_taxonomy( $taxonomy );
2954-
foreach ( $tax_object->object_type as $object_type ) {
2955-
clean_object_term_cache( $objects, $object_type );
2956-
}
2957-
29582951
/**
29592952
* Fires after a term has been updated, but before the term cache has been cleaned.
29602953
*

tests/phpunit/tests/term/wpUpdateTerm.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -488,40 +488,6 @@ public function test_wp_update_term_should_return_int_values_for_term_id_and_ter
488488
$this->assertInternalType( 'int', $found['term_taxonomy_id'] );
489489
}
490490

491-
public function test_wp_update_term_should_clean_object_term_cache() {
492-
register_taxonomy( 'wptests_tax_for_post', 'post' );
493-
register_taxonomy( 'wptests_tax_for_page', 'page' );
494-
$post = self::factory()->post->create();
495-
$page = self::factory()->post->create( array(
496-
'post_type' => 'page',
497-
) );
498-
499-
$t_for_post = self::factory()->term->create( array(
500-
'taxonomy' => 'wptests_tax_for_post',
501-
) );
502-
$t_for_page = self::factory()->term->create( array(
503-
'taxonomy' => 'wptests_tax_for_page',
504-
) );
505-
506-
wp_set_post_terms( $post, array( $t_for_post ), 'wptests_tax_for_post' );
507-
wp_set_post_terms( $page, array( $t_for_page ), 'wptests_tax_for_page' );
508-
509-
// Prime caches and verify.
510-
update_object_term_cache( array( $post ), 'post' );
511-
update_object_term_cache( array( $page ), 'page' );
512-
$this->assertNotEmpty( wp_cache_get( $post, 'wptests_tax_for_post_relationships' ) );
513-
$this->assertNotEmpty( wp_cache_get( $page, 'wptests_tax_for_page_relationships' ) );
514-
515-
// Update a term in just one of the taxonomies.
516-
$found = wp_update_term( $t_for_post, 'wptests_tax_for_post', array(
517-
'slug' => 'foo',
518-
) );
519-
520-
// Only the relevant cache should have been cleared.
521-
$this->assertFalse( wp_cache_get( $post, 'wptests_tax_for_post_relationships' ) );
522-
$this->assertNotEmpty( wp_cache_get( $page, 'wptests_tax_for_page_relationships' ) );
523-
}
524-
525491
public function test_wp_update_term_should_clean_term_cache() {
526492
register_taxonomy( 'wptests_tax', 'post', array(
527493
'hierarchical' => true,

0 commit comments

Comments
 (0)