diff --git a/wp-admin/comment.php b/wp-admin/comment.php index 1fb137d92..4bd10c578 100644 --- a/wp-admin/comment.php +++ b/wp-admin/comment.php @@ -216,7 +216,7 @@ case 'approvecomment' : case 'editedcomment' : $comment_id = absint( $_POST['comment_ID'] ); - $comment_post_id = absint( $_POST['comment_post_id'] ); + $comment_post_id = absint( $_POST['comment_post_ID'] ); check_admin_referer( 'update-comment_' . $comment_id ); diff --git a/wp-admin/update-links.php b/wp-admin/update-links.php index a60aa6e44..7b3641652 100644 --- a/wp-admin/update-links.php +++ b/wp-admin/update-links.php @@ -47,10 +47,10 @@ if ( $response['response']['code'] != 200 ) $body = str_replace(array("\r\n", "\r"), "\n", $response['body']); $returns = explode("\n", $body); -foreach ($returns as $return) : +foreach ($returns as $return) { $time = substr($return, 0, 19); $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return); - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) ); -endforeach; + $wdpdb->update( $wpdb->links, array('link_updated' => $time), array('link_url' => $uri) ); +} ?> diff --git a/wp-includes/comment.php b/wp-includes/comment.php index fa27a62b9..4bdf8ddf4 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -880,14 +880,12 @@ function wp_insert_comment($commentdata) { if ( ! isset($comment_type) ) $comment_type = ''; - $result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->comments - (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_karma, comment_approved, comment_agent, comment_type, comment_parent, user_id) - VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %d, %d)", - $comment_post_ID, $comment_author, $comment_author_email, $comment_author_url, $comment_author_IP, $comment_date, $comment_date_gmt, $comment_content, $comment_karma, $comment_approved, $comment_agent, $comment_type, $comment_parent, $user_id) ); + $data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id'); + $wpdb->insert($wpdb->comments, $data); $id = (int) $wpdb->insert_id; - if ( $comment_approved == 1) + if ( $comment_approved == 1 ) wp_update_comment_count($comment_post_ID); $comment = get_comment($id); @@ -1080,8 +1078,7 @@ function wp_update_comment($commentarr) { $comment = get_comment($commentarr['comment_ID'], ARRAY_A); // Escape data pulled from DB. - foreach ( (array) $comment as $key => $value ) - $comment[$key] = $wpdb->escape($value); + $comment = $wpdb->escape($comment); // Merge old and new fields with new fields overwriting old ones. $commentarr = array_merge($comment, $commentarr); @@ -1102,25 +1099,8 @@ function wp_update_comment($commentarr) { else if ( 'approve' == $comment_approved ) $comment_approved = 1; - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->comments SET - comment_content = %s, - comment_author = %s, - comment_author_email = %s, - comment_approved = %s, - comment_karma = %d, - comment_author_url = %s, - comment_date = %s, - comment_date_gmt = %s - WHERE comment_ID = %d", - $comment_content, - $comment_author, - $comment_author_email, - $comment_approved, - $comment_karma, - $comment_author_url, - $comment_date, - $comment_date_gmt, - $comment_ID) ); + $data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt'); + $wpdb->update($wpdb->comments, $data, compact('comment_ID')); $rval = $wpdb->rows_affected; @@ -1219,7 +1199,7 @@ function wp_update_comment_count_now($post_id) { $old = (int) $post->comment_count; $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) ); - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_count = %d WHERE ID = %d", $new, $post_id) ); + $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) ); if ( 'page' == $post->post_type ) clean_page_cache( $post_id ); diff --git a/wp-settings.php b/wp-settings.php index 0f14ac4d2..a2d3b59ca 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -254,7 +254,7 @@ require (ABSPATH . WPINC . '/classes.php'); $db_field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', - 'user_status' => '%d', 'umeta_id' => '%d'); + 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d'); require_wp_db();