Skip to:
Content

BuddyPress.org

Changeset 8320


Ignore:
Timestamp:
04/24/2014 09:59:17 PM (12 years ago)
Author:
boonebgorges
Message:

Update bp_last_activity cache when fetching user last_activity.

The cache doesn't do much when it's not set :)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-classes.php

    r8290 r8320  
    13331333
    13341334                // get cache for single user only
     1335                // @todo Why only single user?
    13351336                if ( ! is_array( $user_id ) ) {
    13361337                        $cache = wp_cache_get( $user_id, 'bp_last_activity' );
    … …  
    13561357                                'activity_id'   => $last_activity->id,
    13571358                        );
     1359                }
     1360
     1361                // If this was a single user query, update the cache
     1362                if ( ! is_array( $user_id ) && isset( $retval[ $user_id ] ) ) {
     1363                        wp_cache_set( $user_id, $retval[ $user_id ], 'bp_last_activity' );
    13581364                }
    13591365
  • trunk/tests/testcases/core/class-bp-core-user.php

    r8290 r8320  
    160160         * @group last_activity
    161161         */
     162        public function test_get_last_activity_store_in_cache() {
     163                $u = $this->create_user();
     164                $time = bp_core_current_time();
     165
     166                // Cache is set during user creation. Clear to reflect actual
     167                // pageload
     168                wp_cache_delete( $u, 'bp_last_activity' );
     169
     170                // prime cache
     171                $a = BP_Core_User::get_last_activity( $u );
     172
     173                $this->assertNotEmpty( wp_cache_get( $u, 'bp_last_activity' ) );
     174        }
     175
     176        /**
     177         * @group last_activity
     178         */
    162179        public function test_update_last_activity() {
    163180                $u = $this->create_user();
Note: See TracChangeset for help on using the changeset viewer.