Changeset 34812
- Timestamp:
- 10/03/2015 09:18:55 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r34811 r34812 4391 4391 4392 4392 $object_terms = get_object_term_cache( $object_id, $taxonomy ); 4393 if ( false === $object_terms ) 4394 $object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) ); 4393 if ( false === $object_terms ) { 4394 $object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) ); 4395 wp_cache_set( $object_id, $object_terms, "{$taxonomy}_relationships" ); 4396 } 4395 4397 4396 4398 if ( is_wp_error( $object_terms ) ) -
trunk/tests/phpunit/tests/term/isObjectInTerm.php
r30205 r34812 101 101 $this->assertTrue( is_object_in_term( $post_ID, 'wptests_tax', $int_tax_name ) ); 102 102 } 103 104 /** 105 * @ticket 32044 106 */ 107 public function test_should_populate_and_hit_relationships_cache() { 108 global $wpdb; 109 110 register_taxonomy( 'wptests_tax', 'post' ); 111 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 112 113 $o = 12345; 114 wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); 115 116 $num_queries = $wpdb->num_queries; 117 $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[0] ) ); 118 $num_queries++; 119 $this->assertSame( $num_queries, $wpdb->num_queries ); 120 121 $this->assertFalse( is_object_in_term( $o, 'wptests_tax', $terms[1] ) ); 122 $this->assertSame( $num_queries, $wpdb->num_queries ); 123 } 124 125 /** 126 * @ticket 32044 127 */ 128 public function test_should_not_be_fooled_by_a_stale_relationship_cache() { 129 global $wpdb; 130 131 register_taxonomy( 'wptests_tax', 'post' ); 132 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 133 134 $o = 12345; 135 wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); 136 137 $num_queries = $wpdb->num_queries; 138 $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[0] ) ); 139 $num_queries++; 140 $this->assertSame( $num_queries, $wpdb->num_queries ); 141 142 wp_set_object_terms( $o, $terms[1], 'wptests_tax' ); 143 144 $num_queries = $wpdb->num_queries; 145 $this->assertTrue( is_object_in_term( $o, 'wptests_tax', $terms[1] ) ); 146 $num_queries++; 147 $this->assertSame( $num_queries, $wpdb->num_queries ); 148 } 103 149 }
Note: See TracChangeset
for help on using the changeset viewer.