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
This commit is contained in:
Sergey Biryukov 2014-06-30 00:40:51 +00:00
parent 923becb506
commit 7584b25252

View File

@ -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']) : '';