Changeset 35117
- Timestamp:
- 10/13/2015 02:57:21 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r35032 r35117 1156 1156 $cache = wp_cache_get( $cache_key, 'terms' ); 1157 1157 if ( false !== $cache ) { 1158 if ( 'all' === $args['fields'] ) { 1159 $cache = array_map( 'get_term', $cache ); 1160 } 1158 1161 1159 1162 /** … … 1495 1498 $_terms[ $term->term_id ] = $term->slug; 1496 1499 } 1497 } else {1498 $_terms = array_map( 'get_term', $terms );1499 1500 } 1500 1501 … … 1508 1509 1509 1510 wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS ); 1511 1512 if ( 'all' === $_fields ) { 1513 $terms = array_map( 'get_term', $terms ); 1514 } 1510 1515 1511 1516 /** This filter is documented in wp-includes/taxonomy */ -
trunk/tests/phpunit/tests/term/getTerms.php
r34998 r35117 1594 1594 /** 1595 1595 * @ticket 14162 1596 * @ticket 34282 1597 */ 1598 public function test_should_return_wp_term_objects_when_pulling_from_the_cache() { 1599 global $wpdb; 1600 1601 register_taxonomy( 'wptests_tax', 'post' ); 1602 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 1603 1604 // Prime the cache. 1605 get_terms( 'wptests_tax', array( 1606 'hide_empty' => false, 1607 'fields' => 'all', 1608 ) ); 1609 1610 $num_queries = $wpdb->num_queries; 1611 1612 $found = get_terms( 'wptests_tax', array( 1613 'hide_empty' => false, 1614 'fields' => 'all', 1615 ) ); 1616 1617 $this->assertSame( $num_queries, $wpdb->num_queries ); 1618 1619 $this->assertNotEmpty( $found ); 1620 1621 foreach ( $found as $term ) { 1622 $this->assertInstanceOf( 'WP_Term', $term ); 1623 } 1624 } 1625 1626 /** 1627 * @ticket 14162 1596 1628 */ 1597 1629 public function test_should_prime_individual_term_cache_when_fields_is_all() {
Note: See TracChangeset
for help on using the changeset viewer.