Make WordPress Core

Changeset 38214


Ignore:
Timestamp:
08/08/2016 01:13:56 PM (8 years ago)
Author:
ocean90
Message:

Taxononmy: Set WP_Term_Query::terms when returning terms from the cache in WP_Term_Query::get_terms().

Merge of [38211] and [38212] to the 4.6 branch.

Props wonderboymusic.
Props boonebgorges for review.
Fixes #37591.

Location:
branches/4.6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/class-wp-term-query.php

    r38182 r38214  
    642642            }
    643643
    644             return $cache;
     644            $this->terms = $cache;
     645            return $this->terms;
    645646        }
    646647
  • branches/4.6/tests/phpunit/tests/term/query.php

    r38182 r38214  
    143143        return $clauses;
    144144    }
     145
     146    /**
     147     * @ticket 37591
     148     */
     149    public function test_terms_is_set() {
     150        register_taxonomy( 'wptests_tax_1', 'post' );
     151
     152        self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_1' ) );
     153
     154        $q1 = new WP_Term_Query( array(
     155            'taxonomy' => 'wptests_tax_1',
     156            'hide_empty' => false
     157        ) );
     158
     159        $this->assertNotEmpty( $q1->terms );
     160
     161        $q2 = new WP_Term_Query( array(
     162            'taxonomy' => 'wptests_tax_1',
     163            'hide_empty' => false
     164        ) );
     165
     166        $this->assertNotEmpty( $q2->terms );
     167    }
    145168}
Note: See TracChangeset for help on using the changeset viewer.