From 31e34400a56e25fbb86c3478767cd9feb0790533 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Sat, 16 Mar 2019 15:22:53 +0000 Subject: [PATCH] Accessibility: Login: Display error messages when both the username and password fields are empty. For accessibility and usability, if an input error is detected, the item that is in error needs to be identified and the error needs to be described to the user in text (WCAG Success Criterion 3.3.1). The login form displays an error when the username field is empty or when the password field is empty. It omits to do so when both fields are empty. This change restores the login form behavior to the one that used to work in WordPress 2.3 (!) and displays the related error messages also when both fields are empty. Props birgire, audrasjb. See #8938, #5405, #3708. Fixes #42985. Built from https://develop.svn.wordpress.org/trunk@44918 git-svn-id: http://core.svn.wordpress.org/trunk@44749 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 4 ---- wp-includes/version.php | 2 +- wp-login.php | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index eb8f0a13aa..3414da0fbc 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -95,10 +95,6 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) { $user = wp_authenticate( $credentials['user_login'], $credentials['user_password'] ); if ( is_wp_error( $user ) ) { - if ( $user->get_error_codes() == array( 'empty_username', 'empty_password' ) ) { - $user = new WP_Error( '', '' ); - } - return $user; } diff --git a/wp-includes/version.php b/wp-includes/version.php index f8bc63a916..fec603fdb2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-alpha-44917'; +$wp_version = '5.2-alpha-44918'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-login.php b/wp-login.php index 72fcae266d..b02a2b9e70 100644 --- a/wp-login.php +++ b/wp-login.php @@ -1007,6 +1007,10 @@ switch ( $action ) { $errors = new WP_Error(); } + if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) { + $errors = new WP_Error( '', '' ); + } + if ( $interim_login ) { if ( ! $errors->has_errors() ) { $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );