Skip to:
Content

BuddyPress.org

Changeset 5096


Ignore:
Timestamp:
09/02/2011 11:21:15 AM (14 years ago)
Author:
boonebgorges
Message:

Get a fresh index each time through the loop when merging profile field data into the profile group array, to avoid errors when empty groups have been removed. Fixes #3542

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r5059 r5096  
    211211
    212212        // Merge the field array back in with the group array
    213         foreach( (array) $groups as $group_key => $group ) {
     213        foreach( (array) $groups as $group ) {
     214
     215            // Indexes may have been shifted after previous deletions, so we get a
     216            // fresh one each time through the loop
     217            $index = array_search( $group, $groups );
     218
    214219            foreach( (array) $fields as $field ) {
    215220                if ( $group->id == $field->group_id )
    216                     $groups[$group_key]->fields[] = $field;
     221                    $groups[$index]->fields[] = $field;
    217222            }
    218223
     
    220225            // Remove them, if necessary.
    221226            if ( empty( $group->fields ) && $hide_empty_groups ) {
    222                 unset( $groups[$group_key] );
     227                unset( $groups[$index] );
    223228            }
    224229
Note: See TracChangeset for help on using the changeset viewer.