Avoid PHP notices in wp-login.php if password reset cookie is not set.

props mdawaffe.
see #29060.

git-svn-id: https://develop.svn.wordpress.org/trunk@29381 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2014-08-06 02:16:51 +00:00
parent 0f01ebb037
commit 31105be6c7
1 changed files with 8 additions and 5 deletions

View File

@ -568,13 +568,16 @@ case 'rp' :
exit; exit;
} }
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
$user = check_password_reset_key( $rp_key, $rp_login ); $user = check_password_reset_key( $rp_key, $rp_login );
} else {
$user = false;
}
if ( is_wp_error($user) ) { if ( ! $user || is_wp_error( $user ) ) {
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
if ( $user->get_error_code() === 'expired_key' ) if ( $user && $user->get_error_code() === 'expired_key' )
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
else else
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );