Make WordPress Core

Changeset 40291 for branches/4.7


Ignore:
Timestamp:
03/14/2017 06:42:57 PM (8 years ago)
Author:
boonebgorges
Message:

Fix the formatting of $taxonomies parameter of 'wp_get_object_terms' filter.

[38667] changed the way that the filter parameters are built. That
changeset didn't fully account for the pre-4.7 format of $taxonomies.

Merge of [40290] to the 4.7 branch.

Props ig_communitysites.
Fixes #40154.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/taxonomy.php

    r39611 r40291  
    18931893
    18941894    $object_ids = implode( ',', $object_ids );
    1895     $taxonomies = implode( ',', $taxonomies );
     1895    $taxonomies = "'" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
    18961896
    18971897    /**
  • branches/4.7/tests/phpunit/tests/term/wpGetObjectTerms.php

    r39611 r40291  
    8686    }
    8787
     88    /**
     89     * @ticket 40154
     90     */
     91    public function test_taxonomies_passed_to_wp_get_object_terms_filter_should_be_quoted() {
     92        register_taxonomy( 'wptests_tax', 'post' );
     93        register_taxonomy( 'wptests_tax_2', 'post' );
     94
     95        add_filter( 'wp_get_object_terms', array( $this, 'wp_get_object_terms_callback' ), 10, 3 );
     96        $terms = wp_get_object_terms( 1, array( 'wptests_tax', 'wptests_tax_2' ) );
     97        remove_filter( 'wp_get_object_terms', array( $this, 'wp_get_object_terms_callback' ), 10, 3 );
     98
     99        $this->assertSame( "'wptests_tax', 'wptests_tax_2'", $this->taxonomies );
     100    }
     101
     102    public function wp_get_object_terms_callback( $terms, $object_ids, $taxonomies ) {
     103        $this->taxonomies = $taxonomies;
     104        return $terms;
     105    }
     106
    88107    public function test_orderby_name() {
    89108        $p = self::factory()->post->create();
Note: See TracChangeset for help on using the changeset viewer.