mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 00:24:52 +01:00
Comments: When a comment fails to insert, remove any invalid characters and try again.
See #21212 git-svn-id: https://develop.svn.wordpress.org/trunk@31263 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
260f671a95
commit
b2642750ce
@ -1925,7 +1925,17 @@ function wp_insert_comment( $commentdata ) {
|
||||
|
||||
$compacted = 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' );
|
||||
if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
|
||||
return false;
|
||||
$fields = array( 'comment_author', 'comment_content' );
|
||||
|
||||
foreach( $fields as $field ) {
|
||||
if ( isset( $compacted[ $field ] ) ) {
|
||||
$post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $compacted[ $field ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$id = (int) $wpdb->insert_id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user