Changeset 58341
- Timestamp:
- 06/05/2024 12:21:46 PM (8 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r58333 r58341 26 26 * 27 27 * @global string $auth_secure_cookie 28 * @global wpdb $wpdb WordPress database abstraction object. 28 29 * 29 30 * @param array $credentials { … … 39 40 */ 40 41 function wp_signon( $credentials = array(), $secure_cookie = '' ) { 42 global $auth_secure_cookie, $wpdb; 43 41 44 if ( empty( $credentials ) ) { 42 45 $credentials = array( … … 99 102 $secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials ); 100 103 101 global $auth_secure_cookie;// XXX ugly hack to pass this to wp_authenticate_cookie().104 // XXX ugly hack to pass this to wp_authenticate_cookie(). 102 105 $auth_secure_cookie = $secure_cookie; 103 106 … … 112 115 wp_set_auth_cookie( $user->ID, $credentials['remember'], $secure_cookie ); 113 116 114 /** 115 * @global wpdb $wpdb WordPress database abstraction object. 116 */ 117 global $wpdb; 118 119 // Flush `user_activation_key` if exists after successful login. 117 // Clear `user_activation_key` after a successful login. 120 118 if ( ! empty( $user->user_activation_key ) ) { 121 119 $wpdb->update( … … 124 122 'user_activation_key' => '', 125 123 ), 126 array( 'ID' => $user->ID ), 127 array( '%s' ), 128 array( '%d' ) 124 array( 'ID' => $user->ID ) 129 125 ); 130 126 131 // Empty user_activation_key object.132 127 $user->user_activation_key = ''; 133 128 } … … 142 137 */ 143 138 do_action( 'wp_login', $user->user_login, $user ); 139 144 140 return $user; 145 141 } … … 307 303 */ 308 304 function wp_authenticate_cookie( $user, $username, $password ) { 305 global $auth_secure_cookie; 306 309 307 if ( $user instanceof WP_User ) { 310 308 return $user; … … 316 314 return new WP_User( $user_id ); 317 315 } 318 319 global $auth_secure_cookie;320 316 321 317 if ( $auth_secure_cookie ) { -
trunk/tests/phpunit/tests/auth.php
r58333 r58341 425 425 426 426 /** 427 * Ensure that the user_activation_key is cleared (if available)after a successful login.427 * Ensure that `user_activation_key` is cleared after a successful login. 428 428 * 429 429 * @ticket 58901 430 * 431 * @covers ::wp_signon 430 432 */ 431 433 public function test_user_activation_key_after_successful_login() { 432 434 global $wpdb; 433 435 434 $ reset_key= get_password_reset_key( $this->user );435 $user 436 $password_reset_key = get_password_reset_key( $this->user ); 437 $user = wp_signon( 436 438 array( 437 439 'user_login' => self::USER_LOGIN, … … 439 441 ) 440 442 ); 443 441 444 $activation_key_from_database = $wpdb->get_var( 442 445 $wpdb->prepare( "SELECT user_activation_key FROM $wpdb->users WHERE ID = %d", $this->user->ID ) 443 446 ); 444 447 445 $this->assertNotWPError( $ reset_key, 'The password reset key was not created.' );448 $this->assertNotWPError( $password_reset_key, 'The password reset key was not created.' ); 446 449 $this->assertNotWPError( $user, 'The user was not authenticated.' ); 447 $this->assertEmpty( $user->user_activation_key, 'The `user_activation_key` was not empty on the user object returned by `wp_signon ` function.' );450 $this->assertEmpty( $user->user_activation_key, 'The `user_activation_key` was not empty on the user object returned by `wp_signon()` function.' ); 448 451 $this->assertEmpty( $activation_key_from_database, 'The `user_activation_key` was not empty in the database.' ); 449 452 }
Note: See TracChangeset
for help on using the changeset viewer.