Database: Don't quote placeholders in queries going through `$wpdb->prepare()`
To bring Core into line with the changes to `$wpdb->prepare()` in WordPress 4.8.2, query placeholders shouldn't be quoted. Props jrf, johnjamesjacoby. Fixes #41983. git-svn-id: https://develop.svn.wordpress.org/trunk@41628 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bd85b7a39b
commit
f5c4c69bf1
|
@ -29,7 +29,7 @@ class WP_Importer {
|
||||||
// Grab all posts in chunks
|
// Grab all posts in chunks
|
||||||
do {
|
do {
|
||||||
$meta_key = $importer_name . '_' . $bid . '_permalink';
|
$meta_key = $importer_name . '_' . $bid . '_permalink';
|
||||||
$sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '%s' LIMIT %d,%d", $meta_key, $offset, $limit );
|
$sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit );
|
||||||
$results = $wpdb->get_results( $sql );
|
$results = $wpdb->get_results( $sql );
|
||||||
|
|
||||||
// Increment offset
|
// Increment offset
|
||||||
|
|
|
@ -996,7 +996,7 @@ function _wp_delete_orphaned_draft_menu_items() {
|
||||||
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
||||||
|
|
||||||
// Delete orphaned draft menu items.
|
// Delete orphaned draft menu items.
|
||||||
$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
|
$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp ) );
|
||||||
|
|
||||||
foreach ( (array) $menu_items_to_delete as $menu_item_id )
|
foreach ( (array) $menu_items_to_delete as $menu_item_id )
|
||||||
wp_delete_post( $menu_item_id, true );
|
wp_delete_post( $menu_item_id, true );
|
||||||
|
|
|
@ -4804,7 +4804,7 @@ function wp_scheduled_delete() {
|
||||||
|
|
||||||
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
||||||
|
|
||||||
$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
|
$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp), ARRAY_A);
|
||||||
|
|
||||||
foreach ( (array) $posts_to_delete as $post ) {
|
foreach ( (array) $posts_to_delete as $post ) {
|
||||||
$post_id = (int) $post['post_id'];
|
$post_id = (int) $post['post_id'];
|
||||||
|
@ -4821,7 +4821,7 @@ function wp_scheduled_delete() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
|
$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp), ARRAY_A);
|
||||||
|
|
||||||
foreach ( (array) $comments_to_delete as $comment ) {
|
foreach ( (array) $comments_to_delete as $comment ) {
|
||||||
$comment_id = (int) $comment['comment_id'];
|
$comment_id = (int) $comment['comment_id'];
|
||||||
|
|
|
@ -3788,7 +3788,7 @@ function _wp_check_split_terms_in_menus( $term_id, $new_term_id, $term_taxonomy_
|
||||||
INNER JOIN {$wpdb->postmeta} AS m2 ON ( m2.post_id = m1.post_id )
|
INNER JOIN {$wpdb->postmeta} AS m2 ON ( m2.post_id = m1.post_id )
|
||||||
INNER JOIN {$wpdb->postmeta} AS m3 ON ( m3.post_id = m1.post_id )
|
INNER JOIN {$wpdb->postmeta} AS m3 ON ( m3.post_id = m1.post_id )
|
||||||
WHERE ( m1.meta_key = '_menu_item_type' AND m1.meta_value = 'taxonomy' )
|
WHERE ( m1.meta_key = '_menu_item_type' AND m1.meta_value = 'taxonomy' )
|
||||||
AND ( m2.meta_key = '_menu_item_object' AND m2.meta_value = '%s' )
|
AND ( m2.meta_key = '_menu_item_object' AND m2.meta_value = %s )
|
||||||
AND ( m3.meta_key = '_menu_item_object_id' AND m3.meta_value = %d )",
|
AND ( m3.meta_key = '_menu_item_object_id' AND m3.meta_value = %d )",
|
||||||
$taxonomy,
|
$taxonomy,
|
||||||
$term_id
|
$term_id
|
||||||
|
|
|
@ -1267,7 +1267,7 @@ class wpdb {
|
||||||
* $wild = '%';
|
* $wild = '%';
|
||||||
* $find = 'only 43% of planets';
|
* $find = 'only 43% of planets';
|
||||||
* $like = $wild . $wpdb->esc_like( $find ) . $wild;
|
* $like = $wild . $wpdb->esc_like( $find ) . $wild;
|
||||||
* $sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_content LIKE '%s'", $like );
|
* $sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_content LIKE %s", $like );
|
||||||
*
|
*
|
||||||
* Example Escape Chain:
|
* Example Escape Chain:
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue