Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 3 years ago

#8789 closed defect (bug) (fixed)

bp_get_the_profile_field_ids should check that groups exist

Reported by: shawfactor Owned by: imath
Priority: normal Milestone: 12.0.0
Component: Extended Profile Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc:

Description

The bp_get_the_profile_field_ids function should incorporate a check that $profile_template->groups before the foreach loop. At present when you use it programmatically it can generate an error in some contexts

this would be an improvement:

if (!empty($profile_template->groups)){

foreach ( $profile_template->groups as $group ) {

if ( ! empty( $group->fields ) ) {

$field_ids = array_merge( $field_ids, wp_list_pluck( $group->fields, 'id' ) );

}

}

}

Change History (5)

#1 @imath
4 years ago

  • Component CoreExtended Profile
  • Keywords needs-patch added
  • Milestone Awaiting ReviewUp Next

#2 @imath
4 years ago

  • Milestone Up Next12.0.0

This ticket was mentioned in PR #140 on buddypress/buddypress by @imath.


3 years ago
#3

  • Keywords has-patch has-unit-tests added; needs-patch removed

Prevent potential errors in bp_get_the_profile_field_ids().

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

dcavins commented on PR #140:


3 years ago
#4

I love the unit tests. 👯‍♀️

#5 @imath
3 years ago

  • Owner set to imath
  • Resolutionfixed
  • Status newclosed

In 13528:

Prevent potential errors in bp_get_the_profile_field_ids()

In case this function is used inside an xProfile group loop having no attached profile fields, instead of generating a notice error, let's simply return an empty string.

Props shawfactor

Fixes #8789
Closes https://github.com/buddypress/buddypress/pull/140

Note: See TracTickets for help on using tickets.