Make WordPress Core

Changeset 40290


Ignore:
Timestamp:
03/14/2017 06:41:26 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.

Props ig_communitysites.
Fixes #40154.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r40275 r40290  
    19171917
    19181918    $object_ids = implode( ',', $object_ids );
    1919     $taxonomies = implode( ',', $taxonomies );
     1919    $taxonomies = "'" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
    19201920
    19211921    /**
  • trunk/tests/phpunit/tests/term/wpGetObjectTerms.php

    r39578 r40290  
    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.