Changeset 48315
- Timestamp:
- 07/05/2020 11:19:35 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-default-filters.php
r48121 r48315 32 32 add_action( 'network_user_new_created_user', 'wp_send_new_user_notifications' ); 33 33 add_filter( 'sanitize_user', 'strtolower' ); 34 add_action( 'deleted_user', 'wp_delete_signup_on_user_delete', 10, 3 ); 34 35 35 36 // Roles. -
trunk/src/wp-includes/ms-functions.php
r48121 r48315 1275 1275 'meta' => $meta, 1276 1276 ); 1277 } 1278 1279 /** 1280 * Deletes am associated signup entry when a user is deleted from the database. 1281 * 1282 * @since 5.5.0 1283 * 1284 * @param int $id ID of the user to delete. 1285 * @param int|null $reassign ID of the user to reassign posts and links to. 1286 * @param WP_User $user User object. 1287 */ 1288 function wp_delete_signup_on_user_delete( $id, $reassign, $user ) { 1289 global $wpdb; 1290 1291 $wpdb->delete( $wpdb->signups, array( 'user_login' => $user->user_login ) ); 1277 1292 } 1278 1293 -
trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php
r48121 r48315 85 85 public function test_should_fail_for_existing_signup_with_same_username() { 86 86 // 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' ); 90 90 91 91 $v = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' ); … … 95 95 public function test_should_not_fail_for_existing_signup_with_same_username_if_signup_is_old() { 96 96 // 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' ); 100 100 101 101 global $wpdb; … … 109 109 public function test_should_fail_for_existing_signup_with_same_email() { 110 110 // 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' ); 114 114 115 115 $v = wpmu_validate_user_signup( 'foo2', 'foo@example.com' ); … … 119 119 public function test_should_not_fail_for_existing_signup_with_same_email_if_signup_is_old() { 120 120 // 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' ); 124 124 125 125 global $wpdb; … … 129 129 $v = wpmu_validate_user_signup( 'foo2', 'foo2@example.com' ); 130 130 $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() ); 131 156 } 132 157
Note: See TracChangeset
for help on using the changeset viewer.