Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/29/2020 05:32:05 PM (6 years ago)
Author:
boonebgorges
Message:

Don't delete user data on delete_user hook on Multisite.

The new function bp_remove_user_data_on_delete_user_hook(), which defaults
to false on Multisite and true otherwise, helps BuddyPress to differentiate
between the use of wp_delete_user() to delete a user account from an
installation (typical on non-Multisite) and its use to remove a user from
a site in a Multisite instance.

Props imath.

Fixes #8175.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/friends/functions.php

    r12160 r12605  
    484484        $this->assertEqualSets( $expected_ids, wp_list_pluck( $actual['data'], 'item_id' ) );
    485485    }
     486
     487    /**
     488     * @ticket BP8175
     489     */
     490    public function test_friends_data_should_be_deleted_on_user_delete_non_multisite() {
     491        if ( is_multisite() ) {
     492            $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' );
     493        }
     494
     495        $u1 = self::factory()->user->create();
     496        $u2 = self::factory()->user->create();
     497
     498        friends_add_friend( $u1, $u2, true );
     499
     500        $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     501
     502        wp_delete_user( $u1 );
     503
     504        $this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     505    }
     506
     507    /**
     508     * @ticket BP8175
     509     */
     510    public function test_xprofile_data_should_be_deleted_on_user_delete_multisite() {
     511        if ( ! is_multisite() ) {
     512            $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
     513        }
     514
     515        $u1 = self::factory()->user->create();
     516        $u2 = self::factory()->user->create();
     517
     518        friends_add_friend( $u1, $u2, true );
     519
     520        $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     521
     522        wpmu_delete_user( $u1 );
     523
     524        $this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     525    }
     526
     527    /**
     528     * @ticket BP8175
     529     */
     530    public function test_xprofile_data_should_not_be_deleted_on_wp_delete_user_multisite() {
     531        if ( ! is_multisite() ) {
     532            $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
     533        }
     534
     535        $u1 = self::factory()->user->create();
     536        $u2 = self::factory()->user->create();
     537
     538        friends_add_friend( $u1, $u2, true );
     539
     540        $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     541
     542        wp_delete_user( $u1 );
     543
     544        $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     545    }
    486546}
Note: See TracChangeset for help on using the changeset viewer.