Opened 12 years ago
Closed 12 years ago
#21512 closed defect (bug) (fixed)
Notice undefined variable $user when posting comment without cookies set
Reported by: | c3mdigital | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Comments | Keywords: | has-patch |
Focuses: | Cc: |
Description
Just noticed this in 3.5 (21468).
Theme: Twentytweleve
No Plugins active
Notice: Undefined variable: user in /Users/chris/Sites/newpatch/wp-includes/comment.php on line 658 Call Stack # Time Memory Function Location 1 0.0025 268152 {main}( ) ../wp-comments-post.php:0 2 0.2503 15399872 wp_new_comment( ) ../wp-comments-post.php:90 3 0.2522 15414424 wp_allow_comment( ) ../comment.php:1358
Which also causes multiple cannot modify headers warnings:
Warning: Cannot modify header information - headers already sent by (output started at /Users/chris/Sites/newpatch/wp-includes/comment.php:658) in /Users/chris/Sites/newpatch/wp-includes/comment.php on line 586 Call Stack # Time Memory Function Location 1 0.0025 268152 {main}( )../wp-comments-post.php:0 2 0.3219 16238192 do_action( ) ../wp-comments-post.php:93 3 0.3219 16239784 call_user_func_array ( ) ../plugin.php:406 4 0.3219 16239816 wp_set_comment_cookies( ) ../plugin.php:406 5 0.3219 16240416 setcookie ( ) ../comment.php:586
Warning: Cannot modify header information - headers already sent by (output started at /Users/chris/Sites/newpatch/wp-includes/comment.php:658) in /Users/chris/Sites/newpatch/wp-includes/pluggable.php on line 884 Call Stack # Time Memory Function Location 1 0.0025 268152 {main}( ) ../wp-comments-post.php:0 2 0.3246 16239184 wp_safe_redirect( ) ../wp-comments-post.php:98 3 0.3250 16239512 wp_redirect( ) ../pluggable.php:931 4 0.3254 16251096 header ( ) ../pluggable.php:884
Steps to reproduce:
- Update to latest version
- Clear cookies and logout or start a new private browsing session.
- Post comment
Wrapping the $user variable with isset() fixes the problem.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
Looks good. It's meant to be a truth check, so ! empty() is proper.