Skip to:
Content

BuddyPress.org

Opened 2 years ago

Closed 17 months ago

#8789 closed defect (bug) (fixed)

bp_get_the_profile_field_ids should check that groups exist

Reported by: shawfactor's profile shawfactor Owned by: imath's profile imath
Milestone: 12.0.0 Priority: normal
Severity: normal Version:
Component: Extended Profile 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
2 years ago

  • Component changed from Core to Extended Profile
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Up Next

#2 @imath
2 years ago

  • Milestone changed from Up Next to 12.0.0

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


17 months 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:


17 months ago
#4

I love the unit tests. 👯‍♀️

#5 @imath
17 months ago

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

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.