Make WordPress Core

Changeset 39959


Ignore:
Timestamp:
01/26/2017 01:49:28 PM (7 years ago)
Author:
ocean90
Message:

Query: Ensure that queries work correctly with post type names with special characters.

Merge of [39952] to the 4.4 branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4/src/wp-includes/query.php

    r37082 r39959  
    30663066        if ( 'any' == $post_type ) {
    30673067            $in_search_post_types = get_post_types( array('exclude_from_search' => false) );
    3068             if ( empty( $in_search_post_types ) )
     3068            if ( empty( $in_search_post_types ) ) {
    30693069                $where .= ' AND 1=0 ';
    3070             else
    3071                 $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $in_search_post_types ) . "')";
     3070            } else {
     3071                $where .= " AND {$wpdb->posts}.post_type IN ('" . join( "', '", array_map( 'esc_sql', $in_search_post_types ) ) . "')";
     3072            }
    30723073        } elseif ( !empty( $post_type ) && is_array( $post_type ) ) {
    3073             $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $post_type) . "')";
     3074            $where .= " AND {$wpdb->posts}.post_type IN ('" . join("', '", esc_sql( $post_type ) ) . "')";
    30743075        } elseif ( ! empty( $post_type ) ) {
    3075             $where .= " AND $wpdb->posts.post_type = '$post_type'";
     3076            $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_type = %s", $post_type );
    30763077            $post_type_object = get_post_type_object ( $post_type );
    30773078        } elseif ( $this->is_attachment ) {
Note: See TracChangeset for help on using the changeset viewer.