WordPress.org

Make WordPress Core

Ticket #27373: 27373.patch

File 27373.patch, 1.5 KB (added by SergeyBiryukov, 7 years ago)
  • src/wp-login.php

     
    755755        if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
    756756                $secure_cookie = false;
    757757
    758         // If cookies are disabled we can't log in even with a valid user+pass
    759         if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
    760                 $user = new WP_Error('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
    761         else
    762                 $user = wp_signon('', $secure_cookie);
     758        $user = wp_signon( '', $secure_cookie );
    763759
     760        if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
     761                if ( headers_sent() ) {
     762                        $user = new WP_Error( 'test_cookie', __( '<strong>ERROR</strong>: Could not set cookies, headers are already sent.' ) );
     763                } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) {
     764                        // If cookies are disabled we can't log in even with a valid user+pass
     765                        $user = new WP_Error( 'test_cookie', __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="http://www.google.com/cookies.html">enable cookies</a> to use WordPress.' ) );
     766                }
     767        }
     768
    764769        $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
    765770        /**
    766771         * Filter the login redirect URL.