Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/11/2020 11:29:36 PM (6 years ago)
Author:
imath
Message:

Ensure cached data is cleared in BP_XProfile_ProfileData::delete_data_for_user().

Data was being deleted in bulk using a direct SQL query, bypassing the xprofile_data_before_delete and xprofile_data_after_delete actions, resulting in stale data persisting in the xprofile cache. This change uses xprofile_delete_field_data() to delete the user's data so that the action hooks are called.

Props dd32, r-a-y, dcavins.

See #8388 (branch 6.0).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0/tests/phpunit/testcases/xprofile/class-bp-xprofile-profiledata.php

    r11737 r12785  
    420420        }
    421421
     422        /**
     423         * @ticket BP8388
     424         * @group xprofile_remove_data
     425         */
     426        public function test_cache_invalidated_when_xprofile_remove_data_called() {
     427                $u = self::factory()->user->create();
     428                $g = self::factory()->xprofile_group->create();
     429                $f = self::factory()->xprofile_field->create( array(
     430                        'field_group_id' => $g,
     431                ) );
     432
     433                xprofile_set_field_data( $f, $u, 'Foo' );
     434                // Prime the cache.
     435                xprofile_get_field_data( $f, $u );
     436                xprofile_remove_data( $u );
     437
     438                $d = new BP_XProfile_ProfileData( $f, $u );
     439                $this->assertFalse( $d->exists() );
     440        }
     441
    422442        public function filter_time() {
    423443                return $this->last_updated;
Note: See TracChangeset for help on using the changeset viewer.