From 7584b25252a2dfd77b86e41be62aed9d94b713af Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 30 Jun 2014 00:40:51 +0000 Subject: [PATCH] Normalize 'user_id' and 'user_ID' values in wp_new_comment() before passing the comment data to 'preprocess_comment' filter. props dkotter. fixes #23231. git-svn-id: https://develop.svn.wordpress.org/trunk@28915 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 8899dc30e8..9629c58a28 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -1742,6 +1742,11 @@ function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) * @return int|bool The ID of the comment on success, false on failure. */ function wp_new_comment( $commentdata ) { + if ( isset( $commentdata['user_ID'] ) ) { + $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; + } + $prefiltered_user_id = $commentdata['user_id']; + /** * Filter a comment's data before it is sanitized and inserted into the database. * @@ -1752,10 +1757,11 @@ function wp_new_comment( $commentdata ) { $commentdata = apply_filters( 'preprocess_comment', $commentdata ); $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; - if ( isset($commentdata['user_ID']) ) + if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) { $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; - elseif ( isset($commentdata['user_id']) ) + } elseif ( isset( $commentdata['user_id'] ) ) { $commentdata['user_id'] = (int) $commentdata['user_id']; + } $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0; $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';