Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/23/2017 05:32:04 PM (8 years ago)
Author:
r-a-y
Message:

Members: Cache invalid users in bp_core_get_core_userdata().

This commit caches non-existent user attempts for the
bp_core_get_core_userdata() function, so subsequent calls for the same
user ID will not ping the database again.

See #7523.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/members/cache.php

    r11101 r11611  
    7979        $this->assertSame( $num_queries, $wpdb->num_queries );
    8080    }
     81
     82    /**
     83     * @group bp_core_get_core_userdata
     84     */
     85    public function test_bp_core_get_core_userdata_should_cache_no_results() {
     86        // Get the userdata for a user that doesn't exist.
     87        bp_core_get_core_userdata( PHP_INT_MAX );
     88
     89        // Assert that the non-existent user's attempt was cached.
     90        $this->assertNotFalse( wp_cache_get( 'bp_core_userdata_' . PHP_INT_MAX, 'bp' ) );
     91    }
    8192}
    8293
Note: See TracChangeset for help on using the changeset viewer.