wp_update_comment

The timeline below displays how wordpress function wp_update_comment has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_id = $data['comment_ID'];
    $comment_post_id = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('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');
    $data = wp_array_slice_assoc($data, $keys);
    $result = $wpdb->update($wpdb->comments, $data, array('comment_ID' => $comment_id));
    if (false === $result) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_id, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_id);
    wp_update_comment_count($comment_post_id);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_id The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_id, $data);
    $comment = get_comment($comment_id);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $result;
}

WordPress Version: 9.5

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 5.9

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 8.6

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 5.8

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 7.8

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 7.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .10

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 6.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .10

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 5.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .11

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 5.5

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 * @since 5.5.0 The `$wp_error` parameter was added.
 * @since 5.5.0 The return values for an invalid comment or post ID
 *              were changed to false instead of 0.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @param bool  $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
 * @return int|false|WP_Error The value 1 if the comment was updated, 0 if not updated.
 *                            False or a WP_Error object on failure.
 */
function wp_update_comment($commentarr, $wp_error = false)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        if ($wp_error) {
            return new WP_Error('invalid_comment_id', __('Invalid comment ID.'));
        } else {
            return false;
        }
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        if ($wp_error) {
            return new WP_Error('invalid_post_id', __('Invalid post ID.'));
        } else {
            return false;
        }
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' === $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' === $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     *              and allow skipping further processing.
     *
     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     * @param array          $comment    The old, unslashed comment data.
     * @param array          $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    // Do not carry on on failure.
    if (is_wp_error($data)) {
        if ($wp_error) {
            return $data;
        } else {
            return false;
        }
    }
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    if (false === $rval) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment in the database.'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int The value 1 if the comment was updated, 0 if not updated.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .12

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int The value 1 if the comment was updated, 0 if not updated.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 5.4

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int The value 1 if the comment was updated, 0 if not updated.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields.
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 3.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .14

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 2.3

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .20

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 2.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .17

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 1.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .15

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 0.3

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .20

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 0.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .18

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 9.3

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .22

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.9

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @since 4.9.0 Add updating comment meta during comment update.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    // If metadata is provided, store it.
    if (isset($commentarr['comment_meta']) && is_array($commentarr['comment_meta'])) {
        foreach ($commentarr['comment_meta'] as $meta_key => $meta_value) {
            update_comment_meta($comment_ID, $meta_key, $meta_value);
        }
    }
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 7.1

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.7

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    /**
     * Filters the comment data immediately before it is updated in the database.
     *
     * Note: data being passed to the filter is already unslashed.
     *
     * @since 4.7.0
     *
     * @param array $data       The new, processed comment data.
     * @param array $comment    The old, unslashed comment data.
     * @param array $commentarr The new, raw comment data.
     */
    $data = apply_filters('wp_update_comment_data', $data, $comment, $commentarr);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 6.3

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .25

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.6

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filters the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     * @since 4.6.0 Added the `$data` parameter.
     *
     * @param int   $comment_ID The comment ID.
     * @param array $data       Comment data.
     */
    do_action('edit_comment', $comment_ID, $data);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 5.4

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .30

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 5.3

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .28

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.5

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (!empty($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.4

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .30

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.3

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .29

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 3.4

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .30

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 2.4

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .34

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.2

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 1.5

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .40

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 1.4

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .37

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.1

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 0.4

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .37

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 4.0

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } else if ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } else if ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 3.8

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    extract(wp_unslash($commentarr), EXTR_SKIP);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $comment_content = apply_filters('comment_save_pre', $comment_content);
    $comment_date_gmt = get_gmt_from_date($comment_date);
    if (!isset($comment_approved)) {
        $comment_approved = 1;
    } else if ('hold' == $comment_approved) {
        $comment_approved = 0;
    } else if ('approve' == $comment_approved) {
        $comment_approved = 1;
    }
    $data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 7.5

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    extract(wp_unslash($commentarr), EXTR_SKIP);
    $comment_content = apply_filters('comment_save_pre', $comment_content);
    $comment_date_gmt = get_gmt_from_date($comment_date);
    if (!isset($comment_approved)) {
        $comment_approved = 1;
    } else if ('hold' == $comment_approved) {
        $comment_approved = 0;
    } else if ('approve' == $comment_approved) {
        $comment_approved = 1;
    }
    $data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: .40

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    $filter_comment = false;
    if (!has_filter('pre_comment_content', 'wp_filter_kses')) {
        $filter_comment = !user_can(isset($comment['user_id']) ? $comment['user_id'] : 0, 'unfiltered_html');
    }
    if ($filter_comment) {
        add_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    if ($filter_comment) {
        remove_filter('pre_comment_content', 'wp_filter_kses');
    }
    // Now extract the merged array.
    extract(wp_unslash($commentarr), EXTR_SKIP);
    $comment_content = apply_filters('comment_save_pre', $comment_content);
    $comment_date_gmt = get_gmt_from_date($comment_date);
    if (!isset($comment_approved)) {
        $comment_approved = 1;
    } else if ('hold' == $comment_approved) {
        $comment_approved = 0;
    } else if ('approve' == $comment_approved) {
        $comment_approved = 1;
    }
    $data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}

WordPress Version: 3.7

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    extract(wp_unslash($commentarr), EXTR_SKIP);
    $comment_content = apply_filters('comment_save_pre', $comment_content);
    $comment_date_gmt = get_gmt_from_date($comment_date);
    if (!isset($comment_approved)) {
        $comment_approved = 1;
    } else if ('hold' == $comment_approved) {
        $comment_approved = 0;
    } else if ('approve' == $comment_approved) {
        $comment_approved = 1;
    }
    $data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}