Users: Make sure wp_logout()
clears current user, so that a subsequent call to is_user_logged_in()
works as expected.
Props sebastian.pisula, donmhico, roytanck, juliobox. Fixes #35488. git-svn-id: https://develop.svn.wordpress.org/trunk@46467 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
572934992f
commit
a8259b8c5e
@ -571,6 +571,7 @@ if ( ! function_exists( 'wp_logout' ) ) :
|
||||
function wp_logout() {
|
||||
wp_destroy_current_session();
|
||||
wp_clear_auth_cookie();
|
||||
wp_set_current_user( 0 );
|
||||
|
||||
/**
|
||||
* Fires after a user is logged-out.
|
||||
|
@ -1750,7 +1750,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||
* @ticket 17253
|
||||
*/
|
||||
function test_cpt_with_page_capability_type() {
|
||||
|
||||
register_post_type(
|
||||
'page_capability',
|
||||
array(
|
||||
@ -1799,8 +1798,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
public function testNonLoggedInUsersHaveNoCapabilities() {
|
||||
|
||||
public function test_non_logged_in_users_have_no_capabilities() {
|
||||
$this->assertFalse( is_user_logged_in() );
|
||||
|
||||
$caps = $this->getAllCapsAndRoles();
|
||||
@ -1817,6 +1815,20 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||
$this->assertFalse( current_user_can( 'do_not_allow' ), 'Non-logged-in user should not have the do_not_allow capability' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35488
|
||||
*/
|
||||
function test_wp_logout_should_clear_current_user() {
|
||||
$user_id = self::factory()->user->create();
|
||||
wp_set_current_user( $user_id );
|
||||
|
||||
wp_logout();
|
||||
|
||||
$this->assertEquals( 0, get_current_user_id() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected $_role_test_wp_roles_role;
|
||||
/**
|
||||
* @ticket 23016
|
||||
|
Loading…
x
Reference in New Issue
Block a user