Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2024 06:19:06 PM (5 months ago)
Author:
espellcaste
Message:

A user is no longer de-authenticated when making REST API requests.

We are introducing a new BP_LoggedIn_User class to fetch data about a BuddyPress logged-in user. This new addition fixes an issue where a user could be de-authenticated when making REST API requests.

Props dcavins, DJPaul, johnjamesjacoby, and imath.

Closes https://github.com/buddypress/buddypress/pull/395
See #9229 and #9145
Fixes #7658

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/activity/notifications.php

    r13980 r14070  
    2020        $this->u1 = self::factory()->user->create();
    2121        $this->u2 = self::factory()->user->create();
    22         self::set_current_user( $this->u1 );
     22        wp_set_current_user( $this->u1 );
    2323
    2424        /**
     
    3232
    3333    public function tear_down() {
    34         self::set_current_user( $this->current_user );
     34        wp_set_current_user( $this->current_user );
    3535        $this->set_permalink_structure( $this->permalink_structure );
    3636
     
    9090
    9191        // Log out
    92         self::set_current_user( 0 );
     92        wp_set_current_user( 0 );
    9393
    9494        // Go to the activity permalink page
     
    110110        $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
    111111
    112         self::set_current_user( $this->u1 );
     112        wp_set_current_user( $this->u1 );
    113113    }
    114114
     
    129129
    130130        // Switch user
    131         self::set_current_user( $this->u2 );
     131        wp_set_current_user( $this->u2 );
    132132
    133133        // Go to the activity permalink page
     
    149149        $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
    150150
    151         self::set_current_user( $this->u1 );
     151        wp_set_current_user( $this->u1 );
    152152    }
    153153
     
    202202
    203203        // Log out
    204         self::set_current_user( 0 );
     204        wp_set_current_user( 0 );
    205205
    206206        // Go to the My Activity page
     
    223223
    224224        // clean up
    225         self::set_current_user( $this->u1 );
     225        wp_set_current_user( $this->u1 );
    226226    }
    227227
     
    242242
    243243        // Log out
    244         self::set_current_user( $this->u2 );
     244        wp_set_current_user( $this->u2 );
    245245
    246246        // Go to the My Activity page
     
    263263
    264264        // clean up
    265         self::set_current_user( $this->u1 );
     265        wp_set_current_user( $this->u1 );
    266266    }
    267267
     
    444444
    445445        // Attempt to mark 'comment_reply' notifications as read for user 2.
    446         self::set_current_user( $this->u2 );
     446        wp_set_current_user( $this->u2 );
    447447        foreach ( $u2_notifications as $i => $n ) {
    448448            $n = bp_activity_format_notifications( $n->component_action, $n->item_id, $n->secondary_item_id, 1, 'array', $n->id );
     
    471471        $u3 = self::factory()->user->create();
    472472
    473         self::set_current_user( $u1 );
     473        wp_set_current_user( $u1 );
    474474        $userdata = get_userdata( $u1 );
    475475
     
    487487        ) );
    488488
    489         self::set_current_user( $u2 );
     489        wp_set_current_user( $u2 );
    490490        $userdata = get_userdata( $u2 );
    491491
     
    503503        self::factory()->comment->update_object( $c1, array( 'comment_approved' => 1 ) );
    504504
    505         self::set_current_user( $u3 );
     505        wp_set_current_user( $u3 );
    506506        $userdata = get_userdata( $u3 );
    507507
     
    543543
    544544        // Reset.
    545         self::set_current_user( $old_user );
     545        wp_set_current_user( $old_user );
    546546        remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    547547        remove_filter( 'comment_flood_filter', '__return_false' );
Note: See TracChangeset for help on using the changeset viewer.