Skip to:
Content

BuddyPress.org

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's profile 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)

4068.diff (983 bytes) - added by Mamaduka 13 years ago.

Download all attachments as: .zip

Change History (5)

#1 @DJPaul
13 years ago

  • Milestone changed from Awaiting Review to 1.6

@Mamaduka
13 years ago

#2 @Mamaduka
13 years ago

  • Keywords has-patch added

Proposed patch, a bit changed logic flow.

#3 @boonebgorges
13 years ago

Looks good.

#4 @boonebgorges
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5899]) Rearranges logic in bp_blogs_record_comment() to avoid PHP notices when a post is left by a non-logged-in user. Fixes #4068. Props Mamaduka

Note: See TracTickets for help on using tickets.