Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#11222 closed defect (bug) (fixed)

PHP Notice while untrashing comment

Reported by: sirzooro's profile sirzooro Owned by:
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.9
Component: Trash Keywords: needs-patch
Focuses: Cc:

Description

Steps to reproduce:

  • create a new comment (if you do not have one);
  • go to the comments list;
  • click "Edit";
  • click "Move to Trash" (you should return to comment list);
  • click "Undo" to untrash comment.

When you do this, following notice will appear:
Notice: Undefined index: user_ID in C:\wordpress29.local\wp-includes\comment.php on line 1079

Function wp_filter_comment() is called by wp_new_comment() and wp_update_comment(). First function uses user_ID, second user_id. First function calls preprocess_comment filter; second one takes data from DB, where field name is in lowercase.

Attachments (2)

comment.php.diff (899 bytes) - added by sirzooro 14 years ago.
workaround
11222.diff (3.6 KB) - added by ryan 14 years ago.

Download all attachments as: .zip

Change History (12)

#1 @sirzooro
14 years ago

Hmm, seems that the easiest workaround is to just check if you have user_ID or user_id - see attached patch.

@sirzooro
14 years ago

workaround

#2 @dd32
14 years ago

IMO, the correct fix here is to kill what ever is setting it to uppercase in the first place if lowercase is expected..

#3 @caesarsgrunt
14 years ago

I don't get this error...

#4 @sirzooro
14 years ago

I have confirmed that this warning appears with default theme and no active plugins.

@ryan
14 years ago

#5 @ryan
14 years ago

The confusion stems from the $user_ID global. Attached patch defines a $user_id global as well, uses $user_id in wp-comments-post.php, and makes $user_id the preferred variable in wp_filter_comment() and wp_new_comment() with back compat checks for $user_ID.

#6 @sirzooro
14 years ago

I think it will be good to also add comment(s) which variable version is preferred.

#7 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12267]) Standardize on user_id instead of user_ID when passing comment data. fixes #11222

#8 @westi
14 years ago

This broke setup_userdata() as the argument is the same name as the global.

#9 @westi
14 years ago

(In [12288]) Restore functionality of setup_userdata() when a user id is supplied. See #11271 and #11222.

#10 @ryan
14 years ago

(In [12300]) Accept either user_id or user_ID. Remove user_id global. see #11271 #11222

Note: See TracTickets for help on using tickets.