Changes in trunk/wp-includes/comment.php [12183:12300]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r12183 r12300 133 133 function &get_comment(&$comment, $output = OBJECT) { 134 134 global $wpdb; 135 $null = null; 135 136 136 137 if ( empty($comment) ) { … … 147 148 } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { 148 149 $_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment)); 150 if ( ! $_comment ) 151 return $null; 149 152 wp_cache_add($_comment->comment_ID, $_comment, 'comment'); 150 153 } … … 491 494 // Simple duplicate check 492 495 // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 493 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' ";496 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' "; 494 497 if ( $comment_author_email ) 495 498 $dupe .= "OR comment_author_email = '$comment_author_email' "; … … 864 867 do_action('trash_comment', $comment_id); 865 868 866 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);867 add_comment_meta($comment_id, '_wp_trash_meta_time', time());868 869 wp_set_comment_status($comment_id, 'trash');870 871 do_action('trashed_comment', $comment_id);872 873 return true;869 if ( wp_set_comment_status($comment_id, 'trash') ) { 870 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 871 add_comment_meta($comment_id, '_wp_trash_meta_time', time() ); 872 do_action('trashed_comment', $comment_id); 873 return true; 874 } 875 876 return false; 874 877 } 875 878 … … 878 881 * 879 882 * @since 2.9.0 880 * @uses do_action() on 'untrash_comment' before un deletion881 * @uses do_action() on 'untrashed_comment' after un deletion883 * @uses do_action() on 'untrash_comment' before untrashing 884 * @uses do_action() on 'untrashed_comment' after untrashing 882 885 * 883 886 * @param int $comment_id Comment ID. … … 890 893 do_action('untrash_comment', $comment_id); 891 894 892 $comment = array('comment_ID'=>$comment_id); 893 894 $status = get_comment_meta($comment_id, '_wp_trash_meta_status', true); 895 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); 895 896 if ( empty($status) ) 896 897 $status = '0'; 897 898 898 $comment['comment_approved'] = $status; 899 900 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 901 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 902 903 wp_update_comment($comment); 904 905 do_action('untrashed_comment', $comment_id); 906 907 return true; 899 if ( wp_set_comment_status($comment_id, $status) ) { 900 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 901 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 902 do_action('untrashed_comment', $comment_id); 903 return true; 904 } 905 906 return false; 907 } 908 909 /** 910 * Marks a comment as Spam 911 * 912 * @since 2.9.0 913 * @uses do_action() on 'spam_comment' before spamming 914 * @uses do_action() on 'spammed_comment' after spamming 915 * 916 * @param int $comment_id Comment ID. 917 * @return mixed False on failure 918 */ 919 function wp_spam_comment($comment_id) { 920 if ( !$comment = get_comment($comment_id) ) 921 return false; 922 923 do_action('spam_comment', $comment_id); 924 925 if ( wp_set_comment_status($comment_id, 'spam') ) { 926 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 927 do_action('spammed_comment', $comment_id); 928 return true; 929 } 930 931 return false; 932 } 933 934 /** 935 * Removes a comment from the Spam 936 * 937 * @since 2.9.0 938 * @uses do_action() on 'unspam_comment' before unspamming 939 * @uses do_action() on 'unspammed_comment' after unspamming 940 * 941 * @param int $comment_id Comment ID. 942 * @return mixed False on failure 943 */ 944 function wp_unspam_comment($comment_id) { 945 if ( ! (int)$comment_id ) 946 return false; 947 948 do_action('unspam_comment', $comment_id); 949 950 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); 951 if ( empty($status) ) 952 $status = '0'; 953 954 if ( wp_set_comment_status($comment_id, $status) ) { 955 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 956 do_action('unspammed_comment', $comment_id); 957 return true; 958 } 959 960 return false; 908 961 } 909 962 … … 1074 1127 */ 1075 1128 function wp_filter_comment($commentdata) { 1076 $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); 1129 if ( isset($commentdata['user_ID']) ) 1130 $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); 1131 elseif ( isset($commentdata['user_id']) ) 1132 $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_id']); 1077 1133 $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']); 1078 1134 $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']); … … 1125 1181 1126 1182 $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; 1127 $commentdata['user_ID'] = (int) $commentdata['user_ID']; 1128 1129 $commentdata['comment_parent'] = absint($commentdata['comment_parent']); 1183 if ( isset($commentdata['user_ID']) ) 1184 $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; 1185 elseif ( isset($commentdata['user_id']) ) 1186 $commentdata['user_id'] = (int) $commentdata['user_id']; 1187 1188 $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0; 1130 1189 $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : ''; 1131 1190 $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; … … 1151 1210 $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment 1152 1211 1153 if ( get_option('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ ID'] )1212 if ( get_option('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_id'] ) 1154 1213 wp_notify_postauthor($comment_ID, $commentdata['comment_type']); 1155 1214 } … … 1202 1261 } 1203 1262 1204 $comment_old = get_comment($comment_id);1263 $comment_old = wp_clone(get_comment($comment_id)); 1205 1264 1206 1265 if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
Note: See TracChangeset
for help on using the changeset viewer.