diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 77bc6171ee..bf4f430e41 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -2208,9 +2208,16 @@ function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment function wp_new_comment( $commentdata, $wp_error = false ) { global $wpdb; + /* + * Normalize `user_ID` to `user_id`, but pass the old key + * to the `preprocess_comment` filter for backward compatibility. + */ if ( isset( $commentdata['user_ID'] ) ) { $commentdata['user_ID'] = (int) $commentdata['user_ID']; $commentdata['user_id'] = $commentdata['user_ID']; + } elseif ( isset( $commentdata['user_id'] ) ) { + $commentdata['user_id'] = (int) $commentdata['user_id']; + $commentdata['user_ID'] = $commentdata['user_id']; } $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0; @@ -2235,11 +2242,13 @@ function wp_new_comment( $commentdata, $wp_error = false ) { $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; + // Normalize `user_ID` to `user_id` again, after the filter. if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) { $commentdata['user_ID'] = (int) $commentdata['user_ID']; $commentdata['user_id'] = $commentdata['user_ID']; } elseif ( isset( $commentdata['user_id'] ) ) { $commentdata['user_id'] = (int) $commentdata['user_id']; + $commentdata['user_ID'] = $commentdata['user_id']; } $commentdata['comment_parent'] = isset( $commentdata['comment_parent'] ) ? absint( $commentdata['comment_parent'] ) : 0; @@ -3587,7 +3596,6 @@ function wp_handle_comment_submission( $comment_data ) { $commentdata = array( 'comment_post_ID' => $comment_post_id, - 'user_ID' => $user_id, ); $commentdata += compact( @@ -3596,7 +3604,8 @@ function wp_handle_comment_submission( $comment_data ) { 'comment_author_url', 'comment_content', 'comment_type', - 'comment_parent' + 'comment_parent', + 'user_id' ); /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 7d4578969c..26e46c5719 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta3-54488'; +$wp_version = '6.1-beta3-54489'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.