Make WordPress Core


Ignore:
Timestamp:
05/30/2016 04:10:16 AM (10 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/wpUpdateTerm.php

    r35242 r37593  
    487487                $this->assertInternalType( 'int', $found['term_id'] );
    488488                $this->assertInternalType( 'int', $found['term_taxonomy_id'] );
    489         }
    490 
    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' ) );
    523489        }
    524490
Note: See TracChangeset for help on using the changeset viewer.