Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/10/2016 05:39:34 PM (8 years ago)
Author:
dcavins
Message:

Invalidate profile field cache on update.

When a profile field’s position is updated in
BP_XProfile_Field::update_position(), the
cached field data was not cleared. This caused
the field to look like it was unchanged.

Fixes #7112.

Props @emrikol, @r-a-y.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field.php

    r10778 r10877  
    184184        $this->assertFalse( wp_cache_get( 12345, 'bp_xprofile_fields' ) );
    185185    }
     186
     187    /**
     188     * @ticket BP7112
     189     */
     190    public function test_update_position_should_invalidate_cache() {
     191        $group = $this->factory->xprofile_group->create();
     192        $field = $this->factory->xprofile_field->create( array(
     193            'field_group_id' => $group,
     194        ) );
     195
     196        // Prime cache.
     197        $fetched_field = xprofile_get_field( $field );
     198        $new_field_order = 12345;
     199
     200        // Update field position.
     201        BP_XProfile_Field::update_position( $field, $new_field_order, $group );
     202
     203        // Cache call should miss; fresh data should be fetched.
     204        $updated_fetched_field = xprofile_get_field( $field );
     205        $this->assertEquals( $new_field_order, $updated_fetched_field->field_order );
     206    }
    186207}
Note: See TracChangeset for help on using the changeset viewer.