Skip to:
Content

BuddyPress.org

Changeset 13797


Ignore:
Timestamp:
04/20/2024 06:48:57 PM (2 years ago)
Author:
espellcaste
Message:

While pulling XProfile group fields objects from cache with the BP_XProfile_Group::get method,
avoid unnecessary queries for the cached bp_xprofile_get_signup_field_ids() function.

See #8976

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-admin.php

    r13668 r13797  
    349349                                                                                 * display for the xprofile admin setup screen.
    350350                                                                                 */
    351                                                                                 $signup_fields[ $_signup_field->id ] = bp_xprofile_admin_get_signup_field( $_signup_field, $signup_group, '' );
     351                                                                                $signup_fields[ $_signup_field->id ] = bp_xprofile_admin_get_signup_field( $_signup_field, $signup_group );
    352352                                                                        }
    353353                                                                }
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-group.php

    r13494 r13797  
    347347                }
    348348
     349                $signup_fields_order = bp_xprofile_get_signup_field_ids();
     350
    349351                // Pull field objects from the cache.
    350352                $fields = array();
    351353                foreach ( $field_ids as $field_id ) {
    352                         if ( true === $r['signup_fields_only'] && ! in_array( $field_id, bp_xprofile_get_signup_field_ids(), true ) ) {
     354                        if ( true === $r['signup_fields_only'] && ! in_array( $field_id, $signup_fields_order, true ) ) {
    353355                                continue;
    354356                        }
  • trunk/tests/phpunit/testcases/xprofile/template.php

    r13528 r13797  
    9494                        array(
    9595                                'field_group_id' => $group_1,
    96                                 'type' => 'textbox',
    97                                 'name' => 'InSignupForm1'
     96                                'type'           => 'textbox',
     97                                'name'           => 'InSignupForm1'
    9898                        )
    9999                );
    … …  
    105105                        array(
    106106                                'field_group_id' => $group_2,
    107                                 'type' => 'textbox',
    108                                 'name' => 'InSignupForm2'
     107                                'type'           => 'textbox',
     108                                'name'           => 'InSignupForm2'
    109109                        )
    110110                );
    … …  
    121121                $this->assertSame( $expected_names, $names );
    122122
     123                // Confirm the fields are in the right order.
     124                $this->assertSame( 'InSignupForm2', $group->fields[1]->name );
     125                $this->assertSame( 'InSignupForm1', $group->fields[2]->name );
     126
    123127                xprofile_delete_field_group( $group_1 );
    124128                xprofile_delete_field_group( $group_2 );
    … …  
    139143                $g3 = self::factory()->xprofile_group->create();
    140144
    141                 $field_in_1 = self::factory()->xprofile_field->create(
     145                self::factory()->xprofile_field->create(
    142146                        [
    143147                                'field_group_id' => $g1,
    … …  
    147151                );
    148152
    149                 $field_in_2 = self::factory()->xprofile_field->create(
     153                self::factory()->xprofile_field->create(
    150154                        [
    151155                                'field_group_id' => $g2,
Note: See TracChangeset for help on using the changeset viewer.