Ticket #6836: 6836.5.diff
File 6836.5.diff, 8.8 KB (added by , 17 years ago) |
---|
-
wp-includes/comment.php
593 593 if ( ! isset($user_id) ) 594 594 $user_id = 0; 595 595 596 $result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->comments 597 (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id) 598 VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d)", 599 $comment_post_ID, $comment_author, $comment_author_email, $comment_author_url, $comment_author_IP, $comment_date, $comment_date_gmt, $comment_content, $comment_approved, $comment_agent, $comment_type, $comment_parent, $user_id) ); 596 $wpdb->insert($wpdb->comments, compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id')); 600 597 601 598 $id = (int) $wpdb->insert_id; 602 599 … … 719 716 function wp_set_comment_status($comment_id, $comment_status) { 720 717 global $wpdb; 721 718 719 $update = false; 722 720 switch ( $comment_status ) { 723 721 case 'hold': 724 $ query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID = %d LIMIT 1", $comment_id);722 $update = array('comment_approved' => '0'); 725 723 break; 726 724 case 'approve': 727 $ query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID = %d LIMIT 1", $comment_id);725 $update = array('comment_approved' => '1'); 728 726 break; 729 727 case 'spam': 730 $ query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID = %d LIMIT 1", $comment_id);728 $update = array('comment_approved' => 'spam'); 731 729 break; 732 730 case 'delete': 733 731 return wp_delete_comment($comment_id); … … 736 734 return false; 737 735 } 738 736 739 if ( !$wpdb->query($query) )737 if ( $update && ! $wpdb->update($wpdb->comments, $update, array('comment_ID' => $comment_id)) ) 740 738 return false; 741 739 742 740 clean_comment_cache($comment_id); … … 781 779 782 780 $comment_date_gmt = get_gmt_from_date($comment_date); 783 781 784 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->comments SET 785 comment_content = %s, 786 comment_author = %s, 787 comment_author_email = %s, 788 comment_approved = %s, 789 comment_author_url = %s, 790 comment_date = %s, 791 comment_date_gmt = %s 792 WHERE comment_ID = %d", 793 $comment_content, 794 $comment_author, 795 $comment_author_email, 796 $comment_approved, 797 $comment_author_url, 798 $comment_date, 799 $comment_date_gmt, 800 $comment_ID) ); 782 $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_author_url', 'comment_date', 'comment_date_gmt'), compact('comment_ID') ); 801 783 802 784 $rval = $wpdb->rows_affected; 803 785 … … 1053 1035 $to_ping = get_to_ping($post_id); 1054 1036 $pinged = get_pung($post_id); 1055 1037 if ( empty($to_ping) ) { 1056 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = %d", $post_id) );1038 $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) ); 1057 1039 return; 1058 1040 } 1059 1041 -
wp-includes/functions.php
328 328 wp_cache_set( $option_name, $newvalue, 'options' ); 329 329 } 330 330 331 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->options SET option_value = %s WHERE option_name = %s", $newvalue, $option_name ) ); 331 $wpdb->update($wpdb->options, array('option_value' => $newvalue), array('option_name' => $option_name) ); 332 332 333 if ( $wpdb->rows_affected == 1 ) { 333 334 do_action( "update_option_{$option_name}", $oldvalue, $_newvalue ); 334 335 return true; … … 370 371 wp_cache_set( 'notoptions', $notoptions, 'options' ); 371 372 } 372 373 373 $wpdb-> query( $wpdb->prepare( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES (%s, %s, %s)", $name, $value, $autoload) );374 $wpdb->insert($wpdb->options, array('option_name' => $name, 'option_value' => $value, 'autoload' => $autoload) ); 374 375 375 376 do_action( "add_option_{$name}", $name, $value ); 376 377 return; … … 528 529 $allowed_types = array( 'video', 'audio' ); 529 530 if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { 530 531 $meta_value = "$url\n$len\n$type\n"; 531 $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) 532 VALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value ) ); 532 $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) ); 533 533 } 534 534 } 535 535 } -
wp-includes/pluggable.php
1196 1196 global $wpdb; 1197 1197 1198 1198 $hash = wp_hash_password($password); 1199 $ query = $wpdb->prepare("UPDATE $wpdb->users SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $hash, $user_id);1200 $wpdb->query($query); 1199 $wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) ); 1200 1201 1201 wp_cache_delete($user_id, 'users'); 1202 1202 } 1203 1203 endif; -
wp-includes/post.php
378 378 global $wpdb; 379 379 380 380 $post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db'); 381 $return = $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET post_type = %s WHERE ID = %d", $post_type,$post_id) );381 $return = $wpdb->update($wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) ); 382 382 383 383 if ( 'page' == $post_type ) 384 384 clean_page_cache($post_id); -
wp-includes/taxonomy.php
1191 1191 } else { 1192 1192 // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. 1193 1193 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; 1194 $wpdb-> query( $wpdb->prepare( "UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $alias->term_id) );1194 $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); 1195 1195 } 1196 1196 } 1197 1197 -
wp-includes/user.php
189 189 } 190 190 191 191 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 192 if ( !$cur ) { 193 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value ) 194 VALUES 195 ( %d, %s, %s )", $user_id, $meta_key, $meta_value) ); 196 } else if ( $cur->meta_value != $meta_value ) { 197 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->usermeta SET meta_value = %s WHERE user_id = %d AND meta_key = %s", $meta_value, $user_id, $meta_key) ); 198 } else { 192 if ( !$cur ) 193 $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); 194 else if ( $cur->meta_value != $meta_value ) 195 $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); 196 else 199 197 return false; 200 }201 198 202 199 wp_cache_delete($user_id, 'users'); 203 200 -
wp-login.php
96 96 $key = wp_generate_password(); 97 97 do_action('retrieve_password_key', $user_login, $key); 98 98 // Now insert the new md5 key into the db 99 $wpdb-> query($wpdb->prepare("UPDATE $wpdb->users SET user_activation_key = %s WHERE user_login = %s", $key,$user_login));99 $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); 100 100 } 101 101 $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; 102 102 $message .= get_option('siteurl') . "\r\n\r\n"; -
xmlrpc.php
1352 1352 if( is_array( $attachments ) ) { 1353 1353 foreach( $attachments as $file ) { 1354 1354 if( strpos( $post_content, $file->guid ) !== false ) { 1355 $wpdb-> query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", $post_ID,$file->ID) );1355 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); 1356 1356 } 1357 1357 } 1358 1358 }