Make WordPress Core


Ignore:
Timestamp:
05/31/2016 12:53:27 PM (10 years ago)
Author:
boonebgorges
Message:

Ensure that get_terms() can accept querystring-style arguments.

Prior to [37572], arguments passed to get_terms() were passed immediately
through wp_parse_args(), which made it possible to pass arguments as a
querystring (hide_empty=0) rather than an array
(array( 'hide_empty' => false )). [37572] moved default argument parsing
into WP_Term_Query, while assuming that arguments passed to get_terms()
would be formatted as an array.

To provide compatibility, we now parse all args passed to get_terms() into
an array before processing.

See #35381.

File:
1 edited

Legend:

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

    r37519 r37599  
    2525                        'update_term_meta_cache' => false,
    2626                ) );
     27
     28                $this->assertEqualSets( array( $term ), $found );
     29        }
     30
     31        /**
     32         * @ticket 35495
     33         * @ticket 35381
     34         */
     35        public function test_legacy_params_as_query_string_should_be_properly_parsed() {
     36                register_taxonomy( 'wptests_tax', 'post' );
     37                $term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     38
     39                $found = get_terms( 'wptests_tax', 'hide_empty=0&fields=ids&update_term_meta_cache=0' );
     40
     41                $this->assertEqualSets( array( $term ), $found );
     42        }
     43
     44        /**
     45         * @ticket 35495
     46         * @ticket 35381
     47         */
     48        public function test_new_params_as_query_string_should_be_properly_parsed() {
     49                register_taxonomy( 'wptests_tax', 'post' );
     50                $term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     51
     52                $found = get_terms( 'taxonomy=wptests_tax&hide_empty=0&fields=ids&update_term_meta_cache=0' );
    2753
    2854                $this->assertEqualSets( array( $term ), $found );
Note: See TracChangeset for help on using the changeset viewer.