[wp-trac] [WordPress Trac] #21512: Notice undefined variable $user when posting comment without cookies set
WordPress Trac
wp-trac at lists.automattic.com
Tue Aug 7 20:13:52 UTC 2012
#21512: Notice undefined variable $user when posting comment without cookies set
--------------------------+------------------------------------
Reporter: c3mdigital | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version:
Severity: normal | Keywords: has-patch dev-feedback
--------------------------+------------------------------------
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:
1. Update to latest version
2. Clear cookies and logout or start a new private browsing session.
3. Post comment
Wrapping the $user variable with isset() fixes the problem.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21512>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list