Login and Registration: Reference every rendered notice in the login form - #12796
Login and Registration: Reference every rendered notice in the login form#12796itzmekhokan wants to merge 1 commit into
Conversation
…form. login_header() splits the login errors into a separate notice per severity and can display both at the same time: `#login_error` for errors and `#login-message` for informational messages. The `aria-describedby` logic on the username and password fields assumed only one of them existed, so when both were displayed, one notice was left unreferenced. It was visible on screen but never announced when focus reached either field. Two defects combined to cause this. `WP_Error::get_error_data()` was called without a code, so it fell back to the first error code and ignored the severity of every other item. The second branch then overwrote the attribute rather than appending to it, so only ever one ID could be emitted. Determine the severities the same way login_header() does, by passing each error code to `WP_Error::get_error_data()`, and reference every notice that is displayed, ordered to match the order they appear in. Reachable without a plugin: after a core update WordPress redirects to wp-login.php with `redirect_to` set to about.php?updated, which adds an informational message to the same WP_Error that a failed login populates. Add end to end coverage for all four states the form can be in. The logic lives inline in the `login` case of wp-login.php, a top-level script the PHPUnit suite does not load. Follow-up to [53707]. See #65777.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
login_header()splits the login errors into a separate notice per severity and can display both at the same time. Thearia-describedbylogic assumed only one of them existed, so when both were displayed one notice was left unreferenced.What the problem was:
#login_error(errors) and#login-message(informational messages) can both render at once, but the association logic could only ever emit a single ID, so the other notice was visible on screen and never announced when focus reached the username or password field.WP_Error::get_error_data()was called without a code, so it fell back to the first error code and ignored the severity of every other item.What the fix does:
login_header()does, by passing each error code toWP_Error::get_error_data(), and references every notice that is actually displayed.Approach and why:
login_header()'s own partition means the IDs cannot drift from what is rendered.login_header()outputs the notices, so the order the descriptions are announced in matches the visual order regardless of error-code order.Trac ticket: https://core.trac.wordpress.org/ticket/65777
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Ticket analysis, tests cases and generate ticket and PR. All changes were reviewed and validated by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.