Comments: Consistently normalize `user_ID` to `user_id` in `wp_new_comment()`.
For backward compatibility, the `user_id` parameter of `wp_new_comment()` can be spelled as `user_ID`, and plugins utilizing the `preprocess_comment` filter or the `comment_post` action should be able to receive both variations. Follow-up to [12267], [12300], [28915], [36038], [53729]. Props peterwilsoncc, SergeyBiryukov. Fixes #56244. Built from https://develop.svn.wordpress.org/trunk@54489 git-svn-id: http://core.svn.wordpress.org/trunk@54048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2fc21e6b79
commit
88ba20042c
|
@ -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'
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue