Skip to:
Content

BuddyPress.org

Opened 9 months ago

Closed 3 months ago

#9290 closed enhancement (fixed)

ERROR THROWN "NEW TOP 10!"

Reported by: potcus's profile potcus Owned by: espellcaste's profile espellcaste
Milestone: 14.5.0 Priority: normal
Severity: normal Version:
Component: Extended Profile Keywords: has-patch needs-testing
Cc: rollybueno

Description

Error Details
=============
An error of type E_ERROR was caused in line 130 of the file .../wp-content/plugins/buddypress/bp-xprofile/classes/class-bp-xprofile-profiledata.php. Error message: Uncaught Error: Object of class WP_Error could not be converted to string in ...wp-content/plugins/buddypress/bp-xprofile/classes/class-bp-xprofile-profiledata.php:130
Stack trace:
#0 ...wp-content/plugins/buddypress/bp-xprofile/classes/class-bp-xprofile-profiledata.php(246): BP_XProfile_ProfileData->exists()
#1 ...wp-content/plugins/buddypress/bp-xprofile/bp-xprofile-functions.php(526): BP_XProfile_ProfileData->save()
#2 .../wp-content/plugins/buddypress/bp-members/bp-members-functions.php(2116): xprofile_set_field_data()
#3 .../wp-content/plugins/buddypress/bp-members/classes/class-bp-signup.php(949): bp_core_activate_signup()
#4 .../wp-content/plugins/buddypress/bp-members/classes/class-bp-members-admin.php(1976): BP_Signup::activate()
#5 .../wp-includes/class-wp-hook.php(324): BP_Members_Admin->signups_admin_load()
#6 .../wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#7 .../wp-includes/plugin.php(517): WP_Hook->do_action()
#8 .../wp-admin/admin.php(238): do_action()
#9 .../wp-admin/users.php(11): require_once('...')
#10 {main}

thrown

Change History (5)

This ticket was mentioned in PR #412 on buddypress/buddypress by @rollybueno.


9 months ago
#1

  • Keywords has-patch added

The exists() method was attempting to convert a WP_Error object to a string when
checking for profile data existence. This fix:

  1. Initializes $retval as false by default
  2. Properly handles WP_Error and empty results from database queries
  3. Ensures consistent boolean return value throughout the method
  4. Removes unnecessary boolean casting in apply_filters_ref_array

This prevents the "Object of class WP_Error could not be converted to string" error
while maintaining the expected boolean return value of the exists() method.

Trac ticket: https://buddypress.trac.wordpress.org/ticket/9290

#2 @rollybueno
9 months ago

  • Cc rollybueno added
  • Keywords needs-testing added

#3 @espellcaste
3 months ago

  • Component changed from Core to Extended Profile
  • Milestone changed from Awaiting Review to 14.5.0
  • Type changed from defect (bug) to enhancement

Good catch! Thanks for the patch.

#4 @espellcaste
3 months ago

In 14170:

Avoid an error attempting to convert a WP_Error object to a string when
checking for profile data existence.

While checking if a profile data exist, let us improve our error handling to avoid a PHP error trying to convert a WP_Error object to a string.

The reason why we might get a WP_Error object is varied, but it implies the data does not exist, and we should fail gracefully rather than throw an error.

Developed in https://github.com/buddypress/buddypress/pull/412/

Props rollybueno and potcus.

See #9290 (14.0)

#5 @espellcaste
3 months ago

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

In 14171:

Avoid an error attempting to convert a WP_Error object to a string when
checking for profile data existence.

While checking if a profile data exist, let us improve our error handling to avoid a PHP error trying to convert a WP_Error object to a string.

The reason why we might get a WP_Error object is varied, but it implies the data does not exist, and we should fail gracefully rather than throw an error.

Props rollybueno and potcus.

Closes https://github.com/buddypress/buddypress/pull/412/
Fixes #9290 (trunk)

Note: See TracTickets for help on using tickets.