WordPress.org

Make WordPress Core

Ticket #10758: 10758-wp-includes-comment.patch

File 10758-wp-includes-comment.patch, 1.2 KB (added by hakre, 9 years ago)

Missing checks for set variables.

  • wp-includes/comment.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress-trunk
     
    11131113function wp_new_comment( $commentdata ) {
    11141114        $commentdata = apply_filters('preprocess_comment', $commentdata);
    11151115
    1116         $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
    1117         $commentdata['user_ID']         = (int) $commentdata['user_ID'];
     1116        $commentdata['comment_post_ID'] = isset($commentdata['comment_post_ID']) ? (int) $commentdata['comment_post_ID'] : null;
     1117        $commentdata['user_ID']         = isset($commentdata['user_ID'])         ? (int) $commentdata['user_ID']         : null;
    11181118
    1119         $commentdata['comment_parent'] = absint($commentdata['comment_parent']);
     1119        $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : null;
    11201120        $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
    11211121        $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
    11221122