From 2f9713104b54e59b90e89de891e49a8acef34319 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sun, 30 Mar 2014 00:41:15 +0000 Subject: [PATCH] Only show test cookie warnings on submit as caching/proxies may intercept the test cookie for GET requests. Introduce a new string for when headers are sent and link them to http://codex.wordpress.org/Cookies (new page). props SergeyBiryukov. fixes #27373. Built from https://develop.svn.wordpress.org/trunk@27859 git-svn-id: http://core.svn.wordpress.org/trunk@27690 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-login.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-login.php b/wp-login.php index 2dce6b3cea..624f65bc53 100644 --- a/wp-login.php +++ b/wp-login.php @@ -755,11 +755,18 @@ default: if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) ) $secure_cookie = false; - // If cookies are disabled we can't log in even with a valid user+pass - if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) ) - $user = new WP_Error('test_cookie', __("ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.")); - else - $user = wp_signon('', $secure_cookie); + $user = wp_signon( '', $secure_cookie ); + + if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { + if ( headers_sent() ) { + $user = new WP_Error( 'test_cookie', sprintf( __( 'ERROR: Cookies are blocked due to unexpected output. For help, please see this documentation or try the support forums.' ), + __( 'http://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) ); + } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { + // If cookies are disabled we can't log in even with a valid user+pass + $user = new WP_Error( 'test_cookie', sprintf( __( 'ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.' ), + __( 'http://codex.wordpress.org/Cookies' ) ) ); + } + } $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; /**