Ticket #16979: 16979.diff
File 16979.diff, 6.0 KB (added by , 14 years ago) |
---|
-
wp-comments-post.php
80 80 wp_die( __('Error: please enter a valid email address.') ); 81 81 } 82 82 83 if ( '' == $comment_content )84 wp_die( __('Error: please type a comment.') );85 86 83 $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; 87 84 88 85 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); -
wp-includes/comment.php
604 604 global $wpdb; 605 605 extract($commentdata, EXTR_SKIP); 606 606 607 // Simple duplicate check 608 // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 609 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' "; 610 if ( $comment_author_email ) 611 $dupe .= "OR comment_author_email = '$comment_author_email' "; 612 $dupe .= ") AND comment_content = '$comment_content' LIMIT 1"; 613 if ( $wpdb->get_var($dupe) ) { 614 do_action( 'comment_duplicate_trigger', $commentdata ); 615 if ( defined('DOING_AJAX') ) 616 die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 607 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt, $commentdata); 617 608 618 wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') );619 }620 621 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );622 623 609 if ( isset($user_id) && $user_id) { 624 610 $userdata = get_userdata($user_id); 625 611 $user = new WP_User($user_id); … … 681 667 } 682 668 683 669 /** 670 * Check whether the comment has been posted already 671 * 672 * 673 * @since 3.2.0 674 * @uses $wpdb 675 * @uses do_action() Calls 'comment_duplicate_trigger' action with the comment data 676 * 677 * @param string $ip Comment IP. 678 * @param string $email Comment author email address. 679 * @param string $date MySQL time string. 680 * @param array $commentdata The pre-processed comment data 681 */ 682 function check_comment_flood_duplicate($ip, $email, $date, $commentdata) { 683 global $wpdb; 684 extract($commentdata, EXTR_SKIP); 685 686 // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 687 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' "; 688 if ( $comment_author_email ) 689 $dupe .= "OR comment_author_email = '$comment_author_email' "; 690 $dupe .= ") AND comment_content = '$comment_content' LIMIT 1"; 691 692 if ( $wpdb->get_var($dupe) ) { 693 do_action( 'comment_duplicate_trigger', $commentdata ); 694 if ( defined('DOING_AJAX') ) 695 die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 696 697 wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 698 } 699 } 700 701 /** 684 702 * Separates an array of comments into an array keyed by comment_type. 685 703 * 686 704 * @since 2.7.0 … … 1223 1241 $comment_type = ''; 1224 1242 1225 1243 $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'); 1244 1245 $data = apply_filters('wp_insert_comment_data', $data); // expect UNslashed 1246 1226 1247 $wpdb->insert($wpdb->comments, $data); 1227 1248 1228 1249 $id = (int) $wpdb->insert_id; … … 1289 1310 } 1290 1311 1291 1312 /** 1313 * Blocks empty comments by wp_die()'ing on empty comments 1314 * 1315 * This function is hooked as such: 1316 * <code>add_filter( 'preprocess_comment', 'disallow_empty_comments', 5);</code> 1317 * 1318 * @since 3.2.0 1319 * 1320 * @param array $commentdata the comment data 1321 * @return array the comment data 1322 */ 1323 function disallow_empty_comments($commentdata) { 1324 if ( '' == $commentdata['comment_content'] ) 1325 wp_die( __('Error: please type a comment.') ); 1326 1327 return $commentdata; 1328 } 1329 1330 /** 1292 1331 * Adds a new comment to the database. 1293 1332 * 1294 1333 * Filters new comment to ensure that the fields are sanitized and valid before … … 1333 1372 1334 1373 $commentdata['comment_approved'] = wp_allow_comment($commentdata); 1335 1374 1375 $commentdata = apply_filters('process_comment', $commentdata); 1376 1336 1377 $comment_ID = wp_insert_comment($commentdata); 1337 1378 1338 1379 do_action('comment_post', $comment_ID, $commentdata['comment_approved']); -
wp-includes/default-filters.php
179 179 add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); 180 180 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 181 181 add_filter( 'sanitize_title', 'sanitize_title_with_dashes' ); 182 add_action( 'check_comment_flood', 'check_comment_flood_duplicate',10, 4 ); 182 183 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); 183 184 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); 184 185 add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); … … 190 191 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); 191 192 add_filter( 'editable_slug', 'urldecode' ); 192 193 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); 194 add_filter( 'preprocess_comment', 'disallow_empty_comments', 5 ); 193 195 194 196 // Atom SSL support 195 add_filter( 'atom_service_url', 'atom_service_url_filter' );197 add_filter( 'atom_service_url', 'atom_service_url_filter' ); 196 198 197 199 // Actions 198 200 add_action( 'wp_head', 'wp_enqueue_scripts', 1 );