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/core/optouts.php

    r13991 r14070  
    3838
    3939        $u1 = self::factory()->user->create();
    40         self::set_current_user( $u1 );
     40        wp_set_current_user( $u1 );
    4141
    4242        // Create a couple of optouts.
     
    5757        $this->assertEqualSets( array( $i1, $i2 ), $optouts );
    5858
    59         self::set_current_user( $old_current_user );
     59        wp_set_current_user( $old_current_user );
    6060    }
    6161
     
    6464
    6565        $u1 = self::factory()->user->create();
    66         self::set_current_user( $u1 );
     66        wp_set_current_user( $u1 );
    6767
    6868        // Create an optouts.
     
    7777        $this->assertEquals( $i1, $i2 );
    7878
    79         self::set_current_user( $old_current_user );
     79        wp_set_current_user( $old_current_user );
    8080    }
    8181
     
    8484
    8585        $u1 = self::factory()->user->create();
    86         self::set_current_user( $u1 );
     86        wp_set_current_user( $u1 );
    8787
    8888        $args = array(
     
    101101        $this->assertEmpty( $optouts );
    102102
    103         self::set_current_user( $old_current_user );
     103        wp_set_current_user( $old_current_user );
    104104    }
    105105
     
    108108
    109109        $u1 = self::factory()->user->create();
    110         self::set_current_user( $u1 );
     110        wp_set_current_user( $u1 );
    111111
    112112        // Create a couple of optouts.
     
    127127        $this->assertEqualSets( array( $i1 ), $optouts );
    128128
    129         self::set_current_user( $old_current_user );
     129        wp_set_current_user( $old_current_user );
    130130    }
    131131
     
    134134
    135135        $u1 = self::factory()->user->create();
    136         self::set_current_user( $u1 );
     136        wp_set_current_user( $u1 );
    137137
    138138        // Create a couple of optouts.
     
    153153        $this->assertEqualSets( array( $i1 ), $optouts );
    154154
    155         self::set_current_user( $old_current_user );
     155        wp_set_current_user( $old_current_user );
    156156    }
    157157
     
    160160
    161161        $u1 = self::factory()->user->create();
    162         self::set_current_user( $u1 );
     162        wp_set_current_user( $u1 );
    163163
    164164        // Create a couple of optouts.
     
    179179        $this->assertEqualSets( array( $i1 ), $optouts );
    180180
    181         self::set_current_user( $old_current_user );
     181        wp_set_current_user( $old_current_user );
    182182    }
    183183
     
    187187
    188188        $u1 = self::factory()->user->create();
    189         self::set_current_user( $u1 );
     189        wp_set_current_user( $u1 );
    190190
    191191        // Create an opt-out.
     
    208208        $this->assertEqualSets( array( $i1 ), $optouts );
    209209
    210         self::set_current_user( $old_current_user );
     210        wp_set_current_user( $old_current_user );
    211211    }
    212212
     
    215215
    216216        $u1 = self::factory()->user->create();
    217         self::set_current_user( $u1 );
     217        wp_set_current_user( $u1 );
    218218        // Create an opt-out.
    219219        $args = array(
     
    228228
    229229        $this->assertTrue( is_wp_error( $email->validate() ) );
    230         self::set_current_user( $old_current_user );
     230        wp_set_current_user( $old_current_user );
    231231    }
    232232}
Note: See TracChangeset for help on using the changeset viewer.