Opened 13 years ago
Closed 13 years ago
#4068 closed defect (bug) (fixed)
bp_blogs_record_comment throws PHP warning when moderating comment
Reported by: | needle | Owned by: | |
---|---|---|---|
Milestone: | 1.6 | Priority: | normal |
Severity: | normal | Version: | 1.5.4 |
Component: | Blogs | Keywords: | has-patch |
Cc: |
Description
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
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
Proposed patch, a bit changed logic flow.