Skip to content

Commit 42e6256

Browse files
committed
Accept either user_id or user_ID. Remove user_id global. see WordPress#11271 WordPress#11222
git-svn-id: https://develop.svn.wordpress.org/trunk@12300 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 7026dd4 commit 42e6256

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

wp-comments-post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
7777

78-
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_id');
78+
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
7979

8080
$comment_id = wp_new_comment( $commentdata );
8181

wp-includes/comment.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,11 +1126,10 @@ function wp_insert_comment($commentdata) {
11261126
* @return array Parsed comment information.
11271127
*/
11281128
function wp_filter_comment($commentdata) {
1129-
// user_id is preferred. user_ID is accepted for back-compat.
11301129
if ( isset($commentdata['user_ID']) )
1131-
$commentdata['user_id'] = $commentdata['user_ID'] = apply_filters('pre_user_id', $commentdata['user_ID']);
1132-
else
1133-
$commentdata['user_id'] = $commentdata['user_ID'] = apply_filters('pre_user_id', $commentdata['user_id']);
1130+
$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']);
1131+
elseif ( isset($commentdata['user_id']) )
1132+
$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_id']);
11341133
$commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']);
11351134
$commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']);
11361135
$commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']);
@@ -1181,11 +1180,10 @@ function wp_new_comment( $commentdata ) {
11811180
$commentdata = apply_filters('preprocess_comment', $commentdata);
11821181

11831182
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
1184-
// user_id is preferred. user_ID is accepted for back-compat.
11851183
if ( isset($commentdata['user_ID']) )
11861184
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
1187-
else
1188-
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_id'];
1185+
elseif ( isset($commentdata['user_id']) )
1186+
$commentdata['user_id'] = (int) $commentdata['user_id'];
11891187

11901188
$commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
11911189
$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';

wp-includes/user.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
451451
* @param int $for_user_id Optional. User ID to setup global data.
452452
*/
453453
function setup_userdata($for_user_id = '') {
454-
global $user_login, $userdata, $user_level, $user_id, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity;
454+
global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity;
455455

456456
if ( '' == $for_user_id )
457457
$user = wp_get_current_user();
@@ -464,7 +464,7 @@ function setup_userdata($for_user_id = '') {
464464
$userdata = $user->data;
465465
$user_login = $user->user_login;
466466
$user_level = (int) isset($user->user_level) ? $user->user_level : 0;
467-
$user_id = $user_ID = (int) $user->ID;
467+
$user_ID = (int) $user->ID;
468468
$user_email = $user->user_email;
469469
$user_url = $user->user_url;
470470
$user_pass_md5 = md5($user->user_pass);

0 commit comments

Comments
 (0)