Make WordPress Core

Ticket #56850: 56850.diff

File 56850.diff, 1.7 KB (added by SergeyBiryukov, 3 years ago)
  • src/wp-includes/user.php

     
    3434        if ( empty( $credentials ) ) {
    3535                $credentials = array(); // Back-compat for plugins passing an empty string.
    3636
     37                $credentials['user_login']    = '';
     38                $credentials['user_password'] = '';
     39
    3740                if ( ! empty( $_POST['log'] ) ) {
    3841                        $credentials['user_login'] = wp_unslash( $_POST['log'] );
    3942                }
  • tests/phpunit/tests/auth.php

     
    429429        }
    430430
    431431        /**
     432         * Tests that PHP 8.1 "passing null to non-nullable" deprecation notices
     433         * are not thrown when `user_login` and `user_password` parameters are empty.
     434         *
     435         * The notices that we should not see:
     436         * `Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated`.
     437         * `Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated`.
     438         *
     439         * @ticket 56850
     440         */
     441        public function test_wp_signon_does_not_throw_deprecation_notices_with_default_parameters() {
     442                $error = wp_signon();
     443                $this->assertWPError( $error, 'The result should be an instance of WP_Error.' );
     444
     445                $error_codes = $error->get_error_codes();
     446                $this->assertContains( 'empty_username', $error_codes, 'The "empty_username" error code should be present.' );
     447                $this->assertContains( 'empty_password', $error_codes, 'The "empty_password" error code should be present.' );
     448        }
     449
     450        /**
    432451         * HTTP Auth headers are used to determine the current user.
    433452         *
    434453         * @ticket 42790