Make WordPress Core


Ignore:
Timestamp:
10/13/2015 02:57:21 AM (11 years ago)
Author:
boonebgorges
Message:

In get_terms(), don't store WP_Term objects in cache.

Fixes #34282.

File:
1 edited

Legend:

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

    r34998 r35117  
    15941594        /**
    15951595         * @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
    15961628         */
    15971629        public function test_should_prime_individual_term_cache_when_fields_is_all() {
Note: See TracChangeset for help on using the changeset viewer.