WordPress.org

Make WordPress Core

Changeset 39952


Ignore:
Timestamp:
01/26/2017 01:32:24 PM (2 years ago)
Author:
ocean90
Message:

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

File:
1 edited

Legend:

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

    r39636 r39952  
    22582258                $where .= ' AND 1=0 ';
    22592259            } else {
    2260                 $where .= " AND {$wpdb->posts}.post_type IN ('" . join("', '", $in_search_post_types ) . "')";
     2260                $where .= " AND {$wpdb->posts}.post_type IN ('" . join( "', '", array_map( 'esc_sql', $in_search_post_types ) ) . "')";
    22612261            }
    22622262        } elseif ( !empty( $post_type ) && is_array( $post_type ) ) {
    2263             $where .= " AND {$wpdb->posts}.post_type IN ('" . join("', '", $post_type) . "')";
     2263            $where .= " AND {$wpdb->posts}.post_type IN ('" . join("', '", esc_sql( $post_type ) ) . "')";
    22642264        } elseif ( ! empty( $post_type ) ) {
    2265             $where .= " AND {$wpdb->posts}.post_type = '$post_type'";
     2265            $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_type = %s", $post_type );
    22662266            $post_type_object = get_post_type_object ( $post_type );
    22672267        } elseif ( $this->is_attachment ) {
Note: See TracChangeset for help on using the changeset viewer.