Changeset 55301
- Timestamp:
- 02/09/2023 01:29:42 AM (22 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r55161 r55301 27 27 * @global string $auth_secure_cookie 28 28 * 29 * @param array $credentials Optional. User info in order to sign on. 29 * @param array $credentials { 30 * Optional. User info in order to sign on. 31 * 32 * @type string $user_login Username. 33 * @type string $user_password User password. 34 * @type bool $remember Whether to 'remember' the user. Increases the time 35 * that the cookie will be kept. Default false. 36 * } 30 37 * @param string|bool $secure_cookie Optional. Whether to use secure cookie. 31 38 * @return WP_User|WP_Error WP_User on success, WP_Error on failure. … … 33 40 function wp_signon( $credentials = array(), $secure_cookie = '' ) { 34 41 if ( empty( $credentials ) ) { 35 $credentials = array(); // Back-compat for plugins passing an empty string. 42 $credentials = array( 43 'user_login' => '', 44 'user_password' => '', 45 'remember' => false, 46 ); 36 47 37 48 if ( ! empty( $_POST['log'] ) ) { -
trunk/tests/phpunit/tests/auth.php
r55250 r55301 443 443 $_POST['pwd'] = $user_args['user_pass']; 444 444 $this->assertInstanceOf( 'WP_User', wp_signon() ); 445 } 446 447 /** 448 * Tests that PHP 8.1 "passing null to non-nullable" deprecation notices 449 * are not thrown when `user_login` and `user_password` parameters are empty. 450 * 451 * The notices that we should not see: 452 * `Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated`. 453 * `Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated`. 454 * 455 * @ticket 56850 456 */ 457 public function test_wp_signon_does_not_throw_deprecation_notices_with_default_parameters() { 458 $error = wp_signon(); 459 $this->assertWPError( $error, 'The result should be an instance of WP_Error.' ); 460 461 $error_codes = $error->get_error_codes(); 462 $this->assertContains( 'empty_username', $error_codes, 'The "empty_username" error code should be present.' ); 463 $this->assertContains( 'empty_password', $error_codes, 'The "empty_password" error code should be present.' ); 445 464 } 446 465
Note: See TracChangeset
for help on using the changeset viewer.