Make WordPress Core


Ignore:
Timestamp:
07/05/2020 11:19:35 AM (4 years ago)
Author:
ocean90
Message:

Multisite: Delete the signup entry when a user is deleted from the database.

When a user has registered with incorrect data and got the account deleted immediately, it currently wasn't possible to register with the same login or email address again due to the existing signup entry. They had to wait for two days until the entry gets automatically deleted. Now the associated signup entry gets deleted as part of the account deletion.

Fixes #43232.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php

    r48121 r48315  
    8585        public function test_should_fail_for_existing_signup_with_same_username() {
    8686            // Don't send notifications.
    87             add_filter( 'wpmu_signup_user_notification', '__return_true' );
    88             wpmu_signup_user( 'foo123', 'foo@example.com' );
    89             remove_filter( 'wpmu_signup_user_notification', '__return_true' );
     87            add_filter( 'wpmu_signup_user_notification', '__return_false' );
     88            wpmu_signup_user( 'foo123', 'foo@example.com' );
     89            remove_filter( 'wpmu_signup_user_notification', '__return_false' );
    9090
    9191            $v = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
     
    9595        public function test_should_not_fail_for_existing_signup_with_same_username_if_signup_is_old() {
    9696            // Don't send notifications.
    97             add_filter( 'wpmu_signup_user_notification', '__return_true' );
    98             wpmu_signup_user( 'foo123', 'foo@example.com' );
    99             remove_filter( 'wpmu_signup_user_notification', '__return_true' );
     97            add_filter( 'wpmu_signup_user_notification', '__return_false' );
     98            wpmu_signup_user( 'foo123', 'foo@example.com' );
     99            remove_filter( 'wpmu_signup_user_notification', '__return_false' );
    100100
    101101            global $wpdb;
     
    109109        public function test_should_fail_for_existing_signup_with_same_email() {
    110110            // Don't send notifications.
    111             add_filter( 'wpmu_signup_user_notification', '__return_true' );
    112             wpmu_signup_user( 'foo123', 'foo@example.com' );
    113             remove_filter( 'wpmu_signup_user_notification', '__return_true' );
     111            add_filter( 'wpmu_signup_user_notification', '__return_false' );
     112            wpmu_signup_user( 'foo123', 'foo@example.com' );
     113            remove_filter( 'wpmu_signup_user_notification', '__return_false' );
    114114
    115115            $v = wpmu_validate_user_signup( 'foo2', 'foo@example.com' );
     
    119119        public function test_should_not_fail_for_existing_signup_with_same_email_if_signup_is_old() {
    120120            // Don't send notifications.
    121             add_filter( 'wpmu_signup_user_notification', '__return_true' );
    122             wpmu_signup_user( 'foo123', 'foo@example.com' );
    123             remove_filter( 'wpmu_signup_user_notification', '__return_true' );
     121            add_filter( 'wpmu_signup_user_notification', '__return_false' );
     122            wpmu_signup_user( 'foo123', 'foo@example.com' );
     123            remove_filter( 'wpmu_signup_user_notification', '__return_false' );
    124124
    125125            global $wpdb;
     
    129129            $v = wpmu_validate_user_signup( 'foo2', 'foo2@example.com' );
    130130            $this->assertNotContains( 'user_email', $v['errors']->get_error_codes() );
     131        }
     132
     133        /**
     134         * @ticket 43232
     135         */
     136        public function test_should_not_fail_for_data_used_by_a_deleted_user() {
     137            global $wpdb;
     138
     139            // Don't send notifications.
     140            add_filter( 'wpmu_signup_user_notification', '__return_false' );
     141            add_filter( 'wpmu_welcome_user_notification', '__return_false' );
     142
     143            // Signup, activate and delete new user.
     144            wpmu_signup_user( 'foo123', 'foo@example.com' );
     145            $key  = $wpdb->get_var( "SELECT activation_key FROM $wpdb->signups WHERE user_login = 'foo123'" );
     146            $user = wpmu_activate_signup( $key );
     147            wpmu_delete_user( $user['user_id'] );
     148
     149            $valid = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
     150
     151            remove_filter( 'wpmu_signup_user_notification', '__return_false' );
     152            remove_filter( 'wpmu_signup_user_notification', '__return_false' );
     153
     154            $this->assertNotContains( 'user_name', $valid['errors']->get_error_codes() );
     155            $this->assertNotContains( 'user_email', $valid['errors']->get_error_codes() );
    131156        }
    132157
Note: See TracChangeset for help on using the changeset viewer.