WordPress.org

Make WordPress Core

Changeset 28457


Ignore:
Timestamp:
05/16/2014 06:51:41 PM (7 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in wp_insert_comment().

See #22400.

File:
1 edited

Legend:

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

    r28437 r28457  
    833833            $approved = 0;
    834834        }
    835        
     835
    836836        if ( wp_blacklist_check(
    837837            $commentdata['comment_author'],
     
    15541554 * @return int The new comment's ID.
    15551555 */
    1556 function wp_insert_comment($commentdata) {
     1556function wp_insert_comment( $commentdata ) {
    15571557    global $wpdb;
    1558     extract(wp_unslash($commentdata), EXTR_SKIP);
    1559 
    1560     if ( ! isset($comment_author_IP) )
    1561         $comment_author_IP = '';
    1562     if ( ! isset($comment_date) )
    1563         $comment_date = current_time('mysql');
    1564     if ( ! isset($comment_date_gmt) )
    1565         $comment_date_gmt = get_gmt_from_date($comment_date);
    1566     if ( ! isset($comment_parent) )
    1567         $comment_parent = 0;
    1568     if ( ! isset($comment_approved) )
    1569         $comment_approved = 1;
    1570     if ( ! isset($comment_karma) )
    1571         $comment_karma = 0;
    1572     if ( ! isset($user_id) )
    1573         $user_id = 0;
    1574     if ( ! isset($comment_type) )
    1575         $comment_type = '';
    1576 
    1577     $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');
    1578     $wpdb->insert($wpdb->comments, $data);
     1558    $data = wp_unslash( $commentdata );
     1559
     1560    $comment_author       = ! isset( $data['comment_author'] )       ? '' : $data['comment_author'];
     1561    $comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email'];
     1562    $comment_author_url   = ! isset( $data['comment_author_url'] )   ? '' : $data['comment_author_url'];
     1563    $comment_author_IP    = ! isset( $data['comment_author_IP'] )    ? '' : $data['comment_author_IP'];
     1564
     1565    $comment_date     = ! isset( $data['comment_date'] )     ? current_time( 'mysql' )            : $data['comment_date'];
     1566    $comment_date_gmt = ! isset( $data['comment_date_gmt'] ) ? get_gmt_from_date( $comment_date ) : $data['comment_date_gmt'];
     1567
     1568    $comment_post_ID  = ! isset( $data['comment_post_ID'] )  ? '' : $data['comment_post_ID'];
     1569    $comment_content  = ! isset( $data['comment_content'] )  ? '' : $data['comment_content'];
     1570    $comment_karma    = ! isset( $data['comment_karma'] )    ? 0  : $data['comment_karma'];
     1571    $comment_approved = ! isset( $data['comment_approved'] ) ? 1  : $data['comment_approved'];
     1572    $comment_agent    = ! isset( $data['comment_agent'] )    ? '' : $data['comment_agent'];
     1573    $comment_type     = ! isset( $data['comment_type'] )     ? '' : $data['comment_type'];
     1574    $comment_parent   = ! isset( $data['comment_parent'] )   ? 0  : $data['comment_parent'];
     1575
     1576    $user_id  = ! isset( $data['user_id'] ) ? 0 : $data['user_id'];
     1577
     1578    $compacted = 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' );
     1579    $wpdb->insert( $wpdb->comments, $compacted );
    15791580
    15801581    $id = (int) $wpdb->insert_id;
    15811582
    1582     if ( $comment_approved == 1 )
    1583         wp_update_comment_count($comment_post_ID);
    1584 
    1585     $comment = get_comment($id);
     1583    if ( $comment_approved == 1 ) {
     1584        wp_update_comment_count( $comment_post_ID );
     1585    }
     1586    $comment = get_comment( $id );
    15861587
    15871588    /**
Note: See TracChangeset for help on using the changeset viewer.