From c8adae8ec77dda2aab52d103a11f0da969d597ce Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 30 Jun 2014 00:41:16 +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. Built from https://develop.svn.wordpress.org/trunk@28915 git-svn-id: http://core.svn.wordpress.org/trunk@28714 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 10 ++++++++-- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 8899dc30e8..9629c58a28 100644 --- a/wp-includes/comment.php +++ b/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']) : ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index f208292b76..402b3ab1e9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.0-alpha-20140629'; +$wp_version = '4.0-alpha-20140630'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.