Opened 15 years ago
Closed 15 years ago
#4068 closed defect (bug) (fixed)
bp_blogs_record_comment throws PHP warning when moderating comment
| Reported by: | needle | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.6 |
| Component: | Blogs | Version: | 1.5.4 |
| Severity: | normal | 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Proposed patch, a bit changed logic flow.