Skip to:
Content

bbPress.org

Opened 4 years ago

Closed 4 years ago

#3402 closed defect (bug) (fixed)

PHP Notice when calling bbp_get_user_nicename() for non-existent users

Reported by: dd32's profile dd32 Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6.6 Priority: normal
Severity: normal Version: 2.6.0
Component: Component - Users Keywords: has-patch
Cc:

Description

Most bbPress functions seem to handle a non-existent user being passed ok, but bbp_get_user_nicename() is not one of them.

PHP Notice: Trying to get property 'user_nicename' of non-object
wp-content/plugins/bbpress/includes/users/template.php:493

The function seems to be designed with the idea that the user might not exist, but it still fails to handle it properly.

See attached patch, which returns false when the userdata can't be found, similar to passing a user_id of 0.

Attachments (2)

3402.diff (1.1 KB) - added by dd32 4 years ago.
3402.2.diff (902 bytes) - added by johnjamesjacoby 4 years ago.
Refresh with some extra checks

Download all attachments as: .zip

Change History (7)

@dd32
4 years ago

#1 @netweb
4 years ago

  • Milestone changed from Awaiting Review to 2.6.6

#2 @johnjamesjacoby
4 years ago

  • Owner set to johnjamesjacoby
  • Status changed from new to assigned
  • Version set to 2.6.0

@johnjamesjacoby
4 years ago

Refresh with some extra checks

#3 @johnjamesjacoby
4 years ago

3402.2.diff does the following:

  • Does the force check first to be more assertive with that argument
  • Switches from $user_id to $r['user_id'] which should be derived from $user_id but may not be
  • Falls back to an empty string so filter always applies

#4 @johnjamesjacoby
4 years ago

In 7143:

Users: avoid PHP notice (warning in PHP8) when getting a user nicename.

This commit improves the internal logic of bbp_get_user_nicename() to handle a missing or invalid user object, defaulting to an empty string in that specific instance.

In branches/2.6, for 2.6.6. See #3402.

Props dd32.

#5 @johnjamesjacoby
4 years ago

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

In 7144:

Users: avoid PHP notice (warning in PHP8) when getting a user nicename.

This commit improves the internal logic of bbp_get_user_nicename() to handle a missing or invalid user object, defaulting to an empty string in that specific instance.

In trunk, for 2.7. Fixes #3402.

Props dd32.

Note: See TracTickets for help on using tickets.