Ticket #6644: prepared_queries1.diff
| File prepared_queries1.diff, 2.7 KB (added by , 18 years ago) |
|---|
-
wp-comments-post.php
11 11 12 12 $comment_post_ID = (int) $_POST['comment_post_ID']; 13 13 14 $status = $wpdb->get_row( "SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'");14 $status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) ); 15 15 16 16 if ( empty($status->comment_status) ) { 17 17 do_action('comment_id_not_found', $comment_post_ID); -
wp-includes/taxonomy.php
749 749 } 750 750 751 751 if ( !empty($taxonomy) ) 752 return $wpdb->get_row( "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = '$taxonomy'", ARRAY_A);752 return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $taxonomy), ARRAY_A); 753 753 754 754 return $wpdb->get_var("SELECT term_id FROM $wpdb->terms as t WHERE $where"); 755 755 } … … 888 888 if ( $ignore_empty ) 889 889 $where = 'AND count > 0'; 890 890 891 $taxonomy = $wpdb->escape( $taxonomy ); 892 return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy' $where"); 891 return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = %s $where", $taxonomy) ); 893 892 } 894 893 895 894 /** … … 918 917 foreach ( $taxonomies as $taxonomy ) { 919 918 $terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); 920 919 $in_terms = "'" . implode("', '", $terms) . "'"; 921 $wpdb->query( "DELETE FROM $wpdb->term_relationships WHERE object_id = '$object_id' AND term_taxonomy_id IN ($in_terms)");920 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_terms)", $object_id) ); 922 921 wp_update_term_count($terms, $taxonomy); 923 922 } 924 923 } … … 1293 1292 $delete_terms = array_diff($old_terms, $tt_ids); 1294 1293 if ( $delete_terms ) { 1295 1294 $in_delete_terms = "'" . implode("', '", $delete_terms) . "'"; 1296 $wpdb->query( "DELETE FROM $wpdb->term_relationships WHERE object_id = '$object_id' AND term_taxonomy_id IN ($in_delete_terms)");1295 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) ); 1297 1296 wp_update_term_count($delete_terms, $taxonomy); 1298 1297 } 1299 1298 }