Make WordPress Core

Ticket #30749: 30749.patch

File 30749.patch, 1.3 KB (added by boonebgorges, 11 years ago)
  • src/wp-includes/taxonomy.php

    diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
    index f407621..1d93f69 100644
    function get_terms( $taxonomies, $args = '' ) { 
    19121912        }
    19131913
    19141914        $terms = $wpdb->get_results($query);
     1915        if ( 'all' == $_fields ) {
     1916                update_term_cache( $terms );
     1917        }
    19151918
    19161919        if ( empty($terms) ) {
    19171920                wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS );
  • tests/phpunit/tests/term/cache.php

    diff --git tests/phpunit/tests/term/cache.php tests/phpunit/tests/term/cache.php
    index d424353..ebb72c6 100644
    class Tests_Term_Cache extends WP_UnitTestCase { 
    9393
    9494                _unregister_taxonomy( $tax );
    9595        }
     96
     97        /**
     98         * @ticket 30749
     99         */
     100        public function test_get_terms_should_update_cache_for_located_terms() {
     101                global $wpdb;
     102
     103                register_taxonomy( 'wptests_tax', 'post' );
     104
     105                $terms = $this->factory->term->create_many( 5, array(
     106                        'taxonomy' => 'wptests_tax',
     107                ) );
     108
     109                $term_objects = get_terms( 'wptests_tax', array(
     110                        'hide_empty' => false,
     111                ) );
     112
     113                $num_queries = $wpdb->num_queries;
     114
     115                foreach ( $terms as $term_id ) {
     116                        get_term( $term_id, 'wptests_tax' );
     117                }
     118
     119                $this->assertSame( $num_queries, $wpdb->num_queries );
     120
     121                _unregister_taxonomy( 'wptests_tax' );
     122        }
    96123}