Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

#8177 closed defect (bug) (fixed)

Admin Issue : Trying to get property ‘show_avatars’ of non-object

Reported by: mangeshnadekar's profile mangeshnadekar Owned by: imath's profile imath
Milestone: 6.0.0 Priority: normal
Severity: normal Version: 5.0.0
Component: Core Keywords: good-first-bug has-patch commit
Cc: shanebp

Description

Hi Team,

I am currently using wordpress version 5.3 in live project.

I have upgraded buddypress form version 2.9.4 to version 5.0.0, now following error messages are displaying in admin dashboard

Notice: Trying to get property ‘show_avatars’ of non-object in wp-content/plugins/buddypress/bp-core/bp-core-avatars.php on line 196

Notice: Undefined offset: 2 in /wp-admin/includes/plugin.php on line 1854

I think it is a buddypress 5.0.0 compatibility issue with wordpress 5.3.

Find attached admin screen shots :

1) http://tinyurl.com/rpgf9k6

2) http://tinyurl.com/uzhoym6

Kindly provide solution.

Attachments (1)

bp-core-avatars.patch (635 bytes) - added by shanebp 5 years ago.

Download all attachments as: .zip

Change History (7)

#1 @imath
5 years ago

  • Keywords reporter-feedback added

Hi @mangeshnadekar

Thanks for your feedback. I wasn't able to reproduce and I don't think it's a BuddyPress issue. Have you tried deactivating all other plugins and switching your active theme to a TwentyYY theme ?

#2 @shanebp
5 years ago

  • Cc shanebp added

I see that notice frequently. Seems to happen when get_avatar is called before $bp->avatar exists. It happens in wp-admin and on any ajax call. It happens with various plugins and some page builders. For example, with Fusion:

wp-content/plugins/buddypress.5.1.0/bp-core/bp-core-avatars.php:200
bp_core_fetch_avatar()
wp-content/plugins/buddypress.5.1.0/bp-core/bp-core-avatars.php:1411
bp_core_get_avatar_data_url_filter()
wp-includes/class-wp-hook.php:288
apply_filters('get_avatar_url')
wp-includes/link-template.php:4249
get_avatar_data()
wp-includes/link-template.php:4017
get_avatar_url()
wp-includes/pluggable.php:2632
get_avatar()
wp-content/plugins/fusion-builder/shortcodes/fusion-user-login.php:170
FusionSC_Login::get_element_extras()
wp-content/plugins/fusion-builder/inc/helpers.php:1922
fusion_builder_frontend_data()
wp-content/plugins/fusion-builder/shortcodes/fusion-user-login.php:1327
fusion_element_login()
wp-includes/class-wp-hook.php:288
do_action('fusion_builder_before_init')
wp-content/plugins/fusion-builder/inc/class-fusion-builder.php:231
FusionBuilder->init()
wp-content/plugins/fusion-builder/inc/class-fusion-builder.php:205
FusionBuilder->__construct()
wp-content/plugins/fusion-builder/inc/class-fusion-builder.php:172
FusionBuilder::get_instance()
wp-content/plugins/fusion-builder/inc/bootstrap.php:41
fusion_builder_activate()
wp-includes/class-wp-hook.php:288
do_action('after_setup_theme')
wp-settings.php:507

The simplest solution is to insert a conditional to see if $bp->avatar exists before the disabled avatars check which throws the notice: ! $bp->avatar->show_avatars.

Last edited 5 years ago by shanebp (previous) (diff)

#3 @imath
5 years ago

  • Keywords needs-patch good-first-bug added; reporter-feedback removed
  • Milestone changed from Awaiting Review to 6.0.0
  • Priority changed from high to normal

Thanks a lot @shanebp for looking deeper into it. Let's do this in 6.0.0. Anyone to suggest a patch ?

#4 @shanebp
5 years ago

This patch simply bails if $bp->avatar does not exist when bp_core_fetch_avatar is called.

#5 @imath
5 years ago

  • Keywords has-patch commit added; needs-patch removed

Thanks for the patch @shanebp It looks good to me.

#6 @imath
5 years ago

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

In 12536:

Prevent errors when get_avatar() is used before BP Globals are set

In this case we need to make sure the buddypress()->avatar object is set before checking its show_avatars property into the function used to filter get_avatar().

Props shanebp

Fixes #8177

Note: See TracTickets for help on using tickets.