Changes in trunk/wp-includes/comment.php [12300:12183]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r12300 r12183 133 133 function &get_comment(&$comment, $output = OBJECT) { 134 134 global $wpdb; 135 $null = null;136 135 137 136 if ( empty($comment) ) { … … 148 147 } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { 149 148 $_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment)); 150 if ( ! $_comment )151 return $null;152 149 wp_cache_add($_comment->comment_ID, $_comment, 'comment'); 153 150 } … … 494 491 // Simple duplicate check 495 492 // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 496 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved != 'trash' AND( comment_author = '$comment_author' ";493 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' "; 497 494 if ( $comment_author_email ) 498 495 $dupe .= "OR comment_author_email = '$comment_author_email' "; … … 867 864 do_action('trash_comment', $comment_id); 868 865 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;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; 877 874 } 878 875 … … 881 878 * 882 879 * @since 2.9.0 883 * @uses do_action() on 'untrash_comment' before un trashing884 * @uses do_action() on 'untrashed_comment' after un trashing880 * @uses do_action() on 'untrash_comment' before undeletion 881 * @uses do_action() on 'untrashed_comment' after undeletion 885 882 * 886 883 * @param int $comment_id Comment ID. … … 893 890 do_action('untrash_comment', $comment_id); 894 891 895 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); 892 $comment = array('comment_ID'=>$comment_id); 893 894 $status = get_comment_meta($comment_id, '_wp_trash_meta_status', true); 896 895 if ( empty($status) ) 897 896 $status = '0'; 898 897 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; 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; 961 908 } 962 909 … … 1127 1074 */ 1128 1075 function wp_filter_comment($commentdata) { 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']); 1076 $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); 1133 1077 $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']); 1134 1078 $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']); … … 1181 1125 1182 1126 $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; 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; 1127 $commentdata['user_ID'] = (int) $commentdata['user_ID']; 1128 1129 $commentdata['comment_parent'] = absint($commentdata['comment_parent']); 1189 1130 $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : ''; 1190 1131 $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; … … 1210 1151 $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment 1211 1152 1212 if ( get_option('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ id'] )1153 if ( get_option('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID'] ) 1213 1154 wp_notify_postauthor($comment_ID, $commentdata['comment_type']); 1214 1155 } … … 1261 1202 } 1262 1203 1263 $comment_old = wp_clone(get_comment($comment_id));1204 $comment_old = get_comment($comment_id); 1264 1205 1265 1206 if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
Note: See TracChangeset
for help on using the changeset viewer.