Ticket #10856: comment_fields.diff

File comment_fields.diff, 2.9 KB (added by scribu, 4 years ago)

Saves new data to comment meta. Still needs code for migrating old data

  • wp-includes/comment.php

     
    10121012        global $wpdb; 
    10131013        extract(stripslashes_deep($commentdata), EXTR_SKIP); 
    10141014 
    1015         if ( ! isset($comment_author_IP) ) 
    1016                 $comment_author_IP = ''; 
    10171015        if ( ! isset($comment_date) ) 
    10181016                $comment_date = current_time('mysql'); 
    10191017        if ( ! isset($comment_date_gmt) ) 
     
    10221020                $comment_parent = 0; 
    10231021        if ( ! isset($comment_approved) ) 
    10241022                $comment_approved = 1; 
    1025         if ( ! isset($comment_karma) ) 
    1026                 $comment_karma = 0; 
    10271023        if ( ! isset($user_id) ) 
    10281024                $user_id = 0; 
    10291025        if ( ! isset($comment_type) ) 
    10301026                $comment_type = ''; 
    10311027 
    1032         $data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id'); 
     1028        $data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent', 'user_id'); 
    10331029        $wpdb->insert($wpdb->comments, $data); 
    10341030 
    10351031        $id = (int) $wpdb->insert_id; 
    10361032 
     1033        // Extra data 
     1034        foreach ( array('comment_author_IP', 'comment_agent', 'comment_karma') as $field ) 
     1035                if ( isset( $$field ) ) 
     1036                        add_comment_meta($id, $field, $$field, true); 
     1037 
    10371038        if ( $comment_approved == 1 ) 
    10381039                wp_update_comment_count($comment_post_ID); 
    10391040 
  • wp-includes/comment-template.php

     
    169169 * @return unknown 
    170170 */ 
    171171function get_comment_author_IP() { 
    172         global $comment; 
    173         return apply_filters('get_comment_author_IP', $comment->comment_author_IP); 
     172        return apply_filters('get_comment_author_IP', get_comment_meta($comment->comment_ID, 'comment_author_IP', true)); 
    174173} 
    175174 
    176175/** 
  • wp-admin/includes/schema.php

     
    6969  comment_author tinytext NOT NULL, 
    7070  comment_author_email varchar(100) NOT NULL default '', 
    7171  comment_author_url varchar(200) NOT NULL default '', 
    72   comment_author_IP varchar(100) NOT NULL default '', 
    7372  comment_date datetime NOT NULL default '0000-00-00 00:00:00', 
    7473  comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', 
    7574  comment_content text NOT NULL, 
    76   comment_karma int(11) NOT NULL default '0', 
    7775  comment_approved varchar(20) NOT NULL default '1', 
    78   comment_agent varchar(255) NOT NULL default '', 
    7976  comment_type varchar(20) NOT NULL default '', 
    8077  comment_parent bigint(20) unsigned NOT NULL default '0', 
    8178  user_id bigint(20) unsigned NOT NULL default '0',