Skip to:
Content

BuddyPress.org

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)

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

Download all attachments as: .zip

Change History (5)

#1 @DJPaul
15 years ago

  • Milestone Awaiting Review → 1.6

@Mamaduka
15 years ago

#2 @Mamaduka
15 years ago

  • Keywords has-patch added

Proposed patch, a bit changed logic flow.

#3 @boonebgorges
15 years ago

Looks good.

#4 @boonebgorges
15 years ago

  • Resolution → fixed
  • Status new → 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.