Changeset 37567
- Timestamp:
- 05/25/2016 06:44:00 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r37544 r37567 2629 2629 2630 2630 // Update termmeta cache, if necessary. 2631 if ( $args['update_term_meta_cache'] && ( 'all' === $fields || 'all_with_object_id s' === $fields || 'term_id' === $fields ) ) {2632 if ( ' term_id' === $fields ) {2633 $term_ids = $ fields;2631 if ( $args['update_term_meta_cache'] && ( 'all' === $fields || 'all_with_object_id' === $fields || 'ids' === $fields ) ) { 2632 if ( 'ids' === $fields ) { 2633 $term_ids = $terms; 2634 2634 } else { 2635 2635 $term_ids = wp_list_pluck( $terms, 'term_id' ); -
trunk/tests/phpunit/tests/term/wpGetObjectTerms.php
r35242 r37567 474 474 475 475 /** 476 * @ticket 36932 477 */ 478 public function test_termmeta_cache_should_be_primed_when_fields_is_all_with_object_id() { 479 global $wpdb; 480 481 register_taxonomy( 'wptests_tax', 'post' ); 482 $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 483 add_term_meta( $terms[0], 'foo', 'bar' ); 484 add_term_meta( $terms[1], 'foo', 'bar' ); 485 add_term_meta( $terms[2], 'foo', 'bar' ); 486 487 $p = self::factory()->post->create(); 488 wp_set_object_terms( $p, $terms, 'wptests_tax' ); 489 490 $found = wp_get_object_terms( $p, 'wptests_tax', array( 491 'update_term_meta_cache' => true, 492 'fields' => 'all_with_object_id', 493 ) ); 494 495 $num_queries = $wpdb->num_queries; 496 497 foreach ( $terms as $t ) { 498 $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) ); 499 } 500 501 $this->assertSame( $num_queries, $wpdb->num_queries ); 502 } 503 504 /** 505 * @ticket 36932 506 */ 507 public function test_termmeta_cache_should_be_primed_when_fields_is_ids() { 508 global $wpdb; 509 510 register_taxonomy( 'wptests_tax', 'post' ); 511 $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 512 add_term_meta( $terms[0], 'foo', 'bar' ); 513 add_term_meta( $terms[1], 'foo', 'bar' ); 514 add_term_meta( $terms[2], 'foo', 'bar' ); 515 516 $p = self::factory()->post->create(); 517 wp_set_object_terms( $p, $terms, 'wptests_tax' ); 518 519 $found = wp_get_object_terms( $p, 'wptests_tax', array( 520 'update_term_meta_cache' => true, 521 'fields' => 'ids', 522 ) ); 523 524 $num_queries = $wpdb->num_queries; 525 526 foreach ( $terms as $t ) { 527 $this->assertSame( 'bar', get_term_meta( $t, 'foo', true ) ); 528 } 529 530 $this->assertSame( $num_queries, $wpdb->num_queries ); 531 } 532 533 /** 476 534 * @ticket 10142 477 535 */
Note: See TracChangeset
for help on using the changeset viewer.