Don't split shared terms on term update.

Splitting shared terms means assigning a new term_id to a given term_taxonomy_id.
It was uncovered that this change could cause problems for sites that have
cached the original term_id somehow - say, in postmeta - since future lookups
using that term_id will now fail.

Removing for 4.1-beta1. We'll look at improvements to backward compatibility
to try to get this back into a later beta.

Props mboynes.
See #30335.

git-svn-id: https://develop.svn.wordpress.org/trunk@30336 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
boonebgorges
2014-11-13 20:04:02 +00:00
parent dc8e01fa9b
commit 805021f406
2 changed files with 0 additions and 144 deletions

View File

@@ -690,88 +690,6 @@ class Tests_Term extends WP_UnitTestCase {
$this->assertSame( 'duplicate_term_slug', $updated->get_error_code() );
}
/**
* @ticket 5809
*/
public function test_wp_update_term_should_split_shared_term() {
global $wpdb;
register_taxonomy( 'wptests_tax', 'post' );
register_taxonomy( 'wptests_tax_2', 'post' );
$t1 = wp_insert_term( 'Foo', 'wptests_tax' );
$t2 = wp_insert_term( 'Foo', 'wptests_tax_2' );
// Manually modify because split terms shouldn't naturally occur.
$wpdb->update( $wpdb->term_taxonomy,
array( 'term_id' => $t1['term_id'] ),
array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
array( '%d' ),
array( '%d' )
);
$posts = $this->factory->post->create_many( 2 );
wp_set_object_terms( $posts[0], array( 'Foo' ), 'wptests_tax' );
wp_set_object_terms( $posts[1], array( 'Foo' ), 'wptests_tax_2' );
// Verify that the terms are shared.
$t1_terms = wp_get_object_terms( $posts[0], 'wptests_tax' );
$t2_terms = wp_get_object_terms( $posts[1], 'wptests_tax_2' );
$this->assertSame( $t1_terms[0]->term_id, $t2_terms[0]->term_id );
wp_update_term( $t2_terms[0]->term_id, 'wptests_tax_2', array(
'name' => 'New Foo',
) );
$t1_terms = wp_get_object_terms( $posts[0], 'wptests_tax' );
$t2_terms = wp_get_object_terms( $posts[1], 'wptests_tax_2' );
$this->assertNotEquals( $t1_terms[0]->term_id, $t2_terms[0]->term_id );
}
/**
* @ticket 5809
*/
public function test_wp_update_term_should_not_split_shared_term_before_410_schema_change() {
global $wpdb;
$db_version = get_option( 'db_version' );
update_option( 'db_version', 30055 );
register_taxonomy( 'wptests_tax', 'post' );
register_taxonomy( 'wptests_tax_2', 'post' );
$t1 = wp_insert_term( 'Foo', 'wptests_tax' );
$t2 = wp_insert_term( 'Foo', 'wptests_tax_2' );
// Manually modify because split terms shouldn't naturally occur.
$wpdb->update( $wpdb->term_taxonomy,
array( 'term_id' => $t1['term_id'] ),
array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
array( '%d' ),
array( '%d' )
);
$posts = $this->factory->post->create_many( 2 );
wp_set_object_terms( $posts[0], array( 'Foo' ), 'wptests_tax' );
wp_set_object_terms( $posts[1], array( 'Foo' ), 'wptests_tax_2' );
// Verify that the term is shared.
$t1_terms = wp_get_object_terms( $posts[0], 'wptests_tax' );
$t2_terms = wp_get_object_terms( $posts[1], 'wptests_tax_2' );
$this->assertSame( $t1_terms[0]->term_id, $t2_terms[0]->term_id );
wp_update_term( $t2_terms[0]->term_id, 'wptests_tax_2', array(
'name' => 'New Foo',
) );
// Term should still be shared.
$t1_terms = wp_get_object_terms( $posts[0], 'wptests_tax' );
$t2_terms = wp_get_object_terms( $posts[1], 'wptests_tax_2' );
$this->assertSame( $t1_terms[0]->term_id, $t2_terms[0]->term_id );
update_option( 'db_version', $db_version );
}
public function test_wp_update_term_alias_of_no_term_group() {
register_taxonomy( 'wptests_tax', 'post' );
$t1 = $this->factory->term->create( array(