Skip to content

Login and Registration: Reference every rendered notice in the login form - #12796

Open
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/login-form-aria-describedby-notices
Open

Login and Registration: Reference every rendered notice in the login form#12796
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/login-form-aria-describedby-notices

Conversation

@itzmekhokan

Copy link
Copy Markdown

login_header() splits the login errors into a separate notice per severity and can display both at the same time. The aria-describedby logic 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.
  • The second branch overwrote the attribute instead of appending to it.

What the fix does:

  • Determines the severities the same way login_header() does, by passing each error code to WP_Error::get_error_data(), and references every notice that is actually displayed.

Approach and why:

  • Mirroring login_header()'s own partition means the IDs cannot drift from what is rendered.
  • IDs are emitted in the order login_header() outputs the notices, so the order the descriptions are announced in matches the visual order regardless of error-code order.
  • No escaping is applied because both IDs are hardcoded literals, consistent with the code being replaced.

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.

…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.
@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props khokansardar.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant