Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/29/2020 05:32:05 PM (4 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/members/functions.php

    r12450 r12605  
    4747        $this->set_current_user( $current_user );
    4848        bp_update_option( 'bp-disable-account-deletion', $deletion_disabled );
     49    }
     50
     51    /**
     52     * @ticket BP8175
     53     */
     54    public function test_last_activity_data_should_be_deleted_on_user_delete_non_multisite() {
     55        if ( is_multisite() ) {
     56            $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' );
     57        }
     58
     59        $u1 = self::factory()->user->create();
     60
     61        $now = time();
     62        bp_update_user_last_activity( $u1, $now );
     63
     64        $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) );
     65
     66        wp_delete_user( $u1 );
     67
     68        $this->assertEquals( '', bp_get_user_last_activity( $u1 ) );
     69    }
     70
     71    /**
     72     * @ticket BP8175
     73     */
     74    public function test_last_activity_data_should_be_deleted_on_user_delete_multisite() {
     75        if ( ! is_multisite() ) {
     76            $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
     77        }
     78
     79        $u1 = self::factory()->user->create();
     80
     81        $now = time();
     82        bp_update_user_last_activity( $u1, $now );
     83
     84        $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) );
     85
     86        wpmu_delete_user( $u1 );
     87
     88        $this->assertEquals( '', bp_get_user_last_activity( $u1 ) );
     89    }
     90
     91    /**
     92     * @ticket BP8175
     93     */
     94    public function test_last_activity_data_should_not_be_deleted_on_wp_delete_user_multisite() {
     95        if ( ! is_multisite() ) {
     96            $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
     97        }
     98
     99        $u1 = self::factory()->user->create();
     100
     101        $now = time();
     102        bp_update_user_last_activity( $u1, $now );
     103
     104        $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) );
     105
     106        wp_delete_user( $u1 );
     107
     108        $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) );
    49109    }
    50110
Note: See TracChangeset for help on using the changeset viewer.