Make WordPress Core

Ticket #28603: 28603.diff

File 28603.diff, 3.1 KB (added by voldemortensen, 10 years ago)
  • src/wp-includes/comment.php

     
    2626 *
    2727 * @global wpdb $wpdb WordPress database abstraction object.
    2828 *
    29  * @param string $author       Comment author name.
    30  * @param string $email        Comment author email.
    31  * @param string $url          Comment author URL.
    32  * @param string $comment      Content of the comment.
    33  * @param string $user_ip      Comment author IP address.
    34  * @param string $user_agent   Comment author User-Agent.
    35  * @param string $comment_type Comment type, either user-submitted comment,
    36  *                                     trackback, or pingback.
     29 * @param string                $author       Comment author name.
     30 * @param string                $email        Comment author email.
     31 * @param string                $url          Comment author URL.
     32 * @param string                $comment      Content of the comment.
     33 * @param string                $user_ip      Comment author IP address.
     34 * @param string                $user_agent   Comment author User-Agent.
     35 * @param string                $comment_type Comment type, either user-submitted comment,
     36 *                                                   trackback, or pingback.
     37 * @param bool|string Optional. $user_id      Comment author ID.
    3738 * @return bool If all checks pass, true, otherwise false.
    3839 */
    39 function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
     40function check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type, $user_id = false ) {
    4041        global $wpdb;
    4142
    4243        // If manual moderation is enabled, skip all checks and return false.
     
    110111         */
    111112        if ( 1 == get_option('comment_whitelist')) {
    112113                if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
    113                         // expected_slashed ($author, $email)
    114                         $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
     114                        if( false == $user_id ) {
     115                                // expected_slashed ($author, $email)
     116                                $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM " . $wpdb->comments . " WHERE comment_author = '" . $author . "' AND comment_author_email = '" . $email . "' and comment_approved = '1' LIMIT 1");
     117                        } else {
     118                                $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM " . $wpdb->comments . " WHERE user_id = '" . $user_id . "' AND comment_approved = '1' LIMIT 1");
     119                        }
    115120                        if ( ( 1 == $ok_to_comment ) &&
    116                                 ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
     121                                ( empty( $mod_keys ) || false === strpos( $email, $mod_keys ) ) )
    117122                                        return true;
    118123                        else
    119124                                return false;
     
    11771182                        $commentdata['comment_content'],
    11781183                        $commentdata['comment_author_IP'],
    11791184                        $commentdata['comment_agent'],
    1180                         $commentdata['comment_type']
     1185                        $commentdata['comment_type'],
     1186                        ( ! empty( $commentdata['user_id'] ) ? $commentdata['user_id'] : false )
    11811187                ) ) {
    11821188                        $approved = 1;
    11831189                } else {