Make WordPress Core

Ticket #23231: 23231.2.diff

File 23231.2.diff, 1.4 KB (added by dkotter, 9 years ago)
  • wp-includes/comment.php

     
    17301730 * @return int The ID of the comment after adding.
    17311731 */
    17321732function wp_new_comment( $commentdata ) {
     1733        if ( isset( $commentdata['user_ID'] ) ) {
     1734                $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
     1735        }
     1736        $prefiltered_user_id = $commentdata['user_id'];
     1737
    17331738        /**
    17341739         * Filter a comment's data before it is sanitized and inserted into the database.
    17351740         *
     
    17401745        $commentdata = apply_filters( 'preprocess_comment', $commentdata );
    17411746
    17421747        $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
    1743         if ( isset($commentdata['user_ID']) )
     1748        if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) {
    17441749                $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
    1745         elseif ( isset($commentdata['user_id']) )
     1750        } elseif ( isset( $commentdata['user_id'] ) ) {
    17461751                $commentdata['user_id'] = (int) $commentdata['user_id'];
     1752        }
    17471753
    17481754        $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
    17491755        $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';