Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#28691 closed defect (bug) (fixed)

wp-login.php wp_attempt_focus does not run on logout

Reported by: mikelittle's profile MikeLittle Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.0 Priority: normal
Severity: normal Version: 4.0
Component: Login and Registration Keywords: has-patch
Focuses: Cc:


Whenever you visit wp-login.php the code runs the JavaScript function wp_attempt_focus to move the focus to the login field. However if the parameter loggedout=true is in the URI, the JavaScript function is not called. Another action is required (tab or click) in order to login again.

The reason the code is not called is because of the following logic:

  • The global variable $error

is set up to hold any errors generated by the processing on the login page.

  • The code to output the call to wp_attempt_focus checks whether the variable has been set.
  • If the variable is set, it does not output the call to the JS function.
  • However, there is a loop in the code line 176 that overwrites the global $error variable
    	foreach ( $wp_error->get_error_messages($code) as $error ) 
  • If I change that loop to use a different interim variable, the Javascript is output and focus is set. Moreover, the correct message "You are now logged out" is still displayed.

Attachments (1)

28691.diff (703 bytes) - added by MikeLittle 10 years ago.
Patch to fix the issue.

Download all attachments as: .zip

Change History (3)

10 years ago

Patch to fix the issue.

#1 @SergeyBiryukov
10 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.0

#2 @SergeyBiryukov
10 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 28925:

Avoid overwriting $error global with an interim variable.

props MikeLittle.
fixes #28691.

Note: See TracTickets for help on using tickets.