Make WordPress Core


Ignore:
Timestamp:
06/30/2014 12:40:51 AM (10 years ago)
Author:
SergeyBiryukov
Message:

Normalize 'user_id' and 'user_ID' values in wp_new_comment() before passing the comment data to 'preprocess_comment' filter.

props dkotter.
fixes #23231.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r28895 r28915  
    17431743 */
    17441744function wp_new_comment( $commentdata ) {
     1745    if ( isset( $commentdata['user_ID'] ) ) {
     1746        $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
     1747    }
     1748    $prefiltered_user_id = $commentdata['user_id'];
     1749
    17451750    /**
    17461751     * Filter a comment's data before it is sanitized and inserted into the database.
     
    17531758
    17541759    $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
    1755     if ( isset($commentdata['user_ID']) )
     1760    if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) {
    17561761        $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
    1757     elseif ( isset($commentdata['user_id']) )
     1762    } elseif ( isset( $commentdata['user_id'] ) ) {
    17581763        $commentdata['user_id'] = (int) $commentdata['user_id'];
     1764    }
    17591765
    17601766    $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
Note: See TracChangeset for help on using the changeset viewer.