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
This commit is contained in:
Sergey Biryukov 2014-06-30 00:41:16 +00:00
parent 63c4cd485f
commit c8adae8ec7
2 changed files with 9 additions and 3 deletions

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

View File

@ -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.