Make WordPress Core


Ignore:
Timestamp:
10/31/2017 01:01:54 PM (7 years ago)
Author:
pento
Message:

Database: Restore numbered placeholders in wpdb::prepare().

[41496] removed support for numbered placeholders in queries send through wpdb::prepare(), which, despite being undocumented, were quite commonly used.

This change restores support for numbered placeholders (as well as a subset of placeholder formatting), while also adding extra checks to ensure the correct number of arguments are being passed to wpdb::prepare(), given the number of placeholders.

Merges [41662], [42056] to the 3.7 branch.
See #41925.

Location:
branches/3.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

  • branches/3.7/src/wp-includes/post.php

    r33561 r42068  
    34953495    $page_path = str_replace('%20', ' ', $page_path);
    34963496    $parts = explode( '/', trim( $page_path, '/' ) );
    3497     $parts = esc_sql( $parts );
    34983497    $parts = array_map( 'sanitize_title_for_query', $parts );
    3499 
    3500     $in_string = "'". implode( "','", $parts ) . "'";
     3498    $escaped_parts = esc_sql( $parts );
     3499
     3500    $in_string = "'". implode( "','", $escaped_parts ) . "'";
    35013501    $post_type_sql = esc_sql( $post_type );
    35023502    $pages = $wpdb->get_results( "SELECT ID, post_name, post_parent, post_type FROM $wpdb->posts WHERE post_name IN ($in_string) AND (post_type = '$post_type_sql' OR post_type = 'attachment')", OBJECT_K );
Note: See TracChangeset for help on using the changeset viewer.