Support » Fixing WordPress » error on wp dashboard login page

  • Hi.
    I actually posted a topic about nine months back regarding this particular issue. Unfortunately the topic is now closed to new comments.

    When you log in to the WP control panel (wp-login.php), the browser shows an error message. It does not prevent you from logging in, so it does not qualify as a bug. But it seems unnecessary.

    I don’t think it needs a screenshot, because most people will have the error message.

    Below is an extract from my original topic (nine months ago):

    ========================

    General issue/question. Since the latest WordPress release 5.2.1 (possibly 5.2.0), you receive an error when you go to the control panel login page ‘wp-login.php’ before you type your username and password.

    ERROR: The username field is empty.
    ERROR: The password field is empty.

    I tracked the new error to several lines of code in ‘wp-includes/user.php’ that were removed.

    Original (before 5.2.1):

    if ( is_wp_error( $user ) ) {
    if ( $user->get_error_codes() == array( 'empty_username', 'empty_password' ) ) {
    $user = new WP_Error( '', '' );
    }
    return $user;
    }

    Present release:

    if ( is_wp_error( $user ) ) {
    return $user;
    }

    ========================

    Why were these lines that prevented the outputted error message taken out?

    • This topic was modified 1 year, 9 months ago by Tom.
    • This topic was modified 1 year, 9 months ago by Tom.
    • This topic was modified 1 year, 9 months ago by Tom.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Josh Feck

    (@builtbynorthby)

    Hi,

    I’m afraid I’m unable to replicate this issue. I see the error message only if I try to submit the log in form when the log in form inputs are empty.

    With regards to your last question, this looks like the related trac ticket:

    https://core.trac.wordpress.org/ticket/42985

    Thread Starter Tom

    (@tnbnicer)

    The errors appear when I open wp-login.php. The user and password fields may be empty at this point, unless the browser stored the username or maybe cached the page, if it can do that with php. But either way, if the fields are empty or the user field is not, the error message remains until I login.

    I could upload a screenshot. …

    Thread Starter Tom

    (@tnbnicer)

    I have to be honest. I inserted the old code in my user.php file. After a recent WP update though, the lines were missing again, and the error resurfaced.

    Thread Starter Tom

    (@tnbnicer)

    Several thoughts:

    1 – trac ticket. Patch 42985.2 applied to wp-login.php.

    wp-login.php:

    if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) {
    	$errors = new WP_Error( '', '' );
    }

    This doesn’t work for me on any browser. If I remove it, it’s just as well.

    I can’t figure out what caused the changes to be made. With the “old” code in user.php an empty field returns an error. When both fields are empty, there’s no error message. Maybe it’s better that way.

    2 – reproducible?

    Apparently the login works on “WordPress.org”, this site. I did not see the errors logging in to post here.

    • This reply was modified 1 year, 9 months ago by Tom.
    • This reply was modified 1 year, 9 months ago by Tom.
    • This reply was modified 1 year, 9 months ago by Tom.
    Thread Starter Tom

    (@tnbnicer)

    Okay. $_POST is not empty. It’s an array with one member already when I open wp-login.php, hence the error messages.

    array (size=1)
    ‘s’ => null

    Although I don’t know how the array is populated. Where does ‘s’ come from?

    Provisionally this works:

    wp-login.php:

    if ( sizeof( $_POST ) < 2 && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) {
    	$errors = new WP_Error( '', '' );
    }
    Thread Starter Tom

    (@tnbnicer)

    A new ticket might be in order, if 42985 can’t be re-opened. Do I have any seconds?

    Thread Starter Tom

    (@tnbnicer)

    A more flexible sizeof( $_POST ) vs. empty( $_POST ) might not be such a bad idea in fact, provided nothing else breaks.

    I found out where the ‘s’ in the array comes from. I can enable and disable pages on my WP site. The minimalist version has one page.

    For many pages I use a search function that I disable with few pages.

    $_GET[‘s’]=null;
    $_POST[‘s’]=null;
    $_REQUEST[‘s’]=null;

    The visitor (or bot) who types a search in the address bar doesn’t head off to a search results page.

    I wonder whether there is better way that would accomplish not setting $_POST['s']?

    A moderator may mark this topic as resolved with my blessing.

    • This reply was modified 1 year, 9 months ago by Tom.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘error on wp dashboard login page’ is closed to new replies.