[buddypress-trac] [BuddyPress] #4068: bp_blogs_record_comment throws PHP warning when moderating comment

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Wed Mar 7 23:25:49 UTC 2012


#4068: bp_blogs_record_comment throws PHP warning when moderating comment
--------------------------+-----------------------------
 Reporter:  needle        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Blogs         |    Version:  1.5.4
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Line 240 of 'wp-content/plugins/buddypress/bp-blogs/bp-blogs-
 functions.php' throws a PHP warning when a comment is posted by someone
 not logged in. Existing code:

 {{{
 $user    = get_user_by( 'email', $recorded_comment->comment_author_email
 );
 $user_id = (int)$user->ID;
 }}}

 $user is not defined when commenter is not logged in, so an extra check is
 needed before accessing the ID property. Something like the following
 should fix this:

 {{{
 $user_id = (int) ( is_object($user) AND isset($user->ID) ) ? $user->ID : 0
 );
 }}}

 Cheers,

 Christian

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4068>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list