Changeset 9231
- Timestamp:
- 12/15/2014 08:38:11 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-functions.php
r9218 r9231 1145 1145 */ 1146 1146 function bp_blogs_total_blogs() { 1147 if ( !$count = wp_cache_get( 'bp_total_blogs', 'bp' ) ) { 1147 $count = wp_cache_get( 'bp_total_blogs', 'bp' ); 1148 1149 if ( false === $count ) { 1148 1150 $blogs = BP_Blogs_Blog::get_all(); 1149 1151 $count = $blogs['total']; -
trunk/src/bp-groups/bp-groups-functions.php
r9226 r9231 645 645 */ 646 646 function groups_get_total_group_count() { 647 if ( !$count = wp_cache_get( 'bp_total_group_count', 'bp' ) ) { 647 $count = wp_cache_get( 'bp_total_group_count', 'bp' ); 648 649 if ( false === $count ) { 648 650 $count = BP_Groups_Group::get_total_group_count(); 649 651 wp_cache_set( 'bp_total_group_count', $count, 'bp' ); … … 685 687 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); 686 688 687 if ( !$count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' ) ) { 689 $count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' ); 690 691 if ( false === $count ) { 688 692 $count = BP_Groups_Member::total_group_count( $user_id ); 689 693 wp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, 'bp' ); -
trunk/src/bp-members/bp-members-functions.php
r9210 r9231 598 598 global $wpdb; 599 599 600 if ( !$count = wp_cache_get( 'bp_total_member_count', 'bp' ) ) { 600 $count = wp_cache_get( 'bp_total_member_count', 'bp' ); 601 602 if ( false === $count ) { 601 603 $status_sql = bp_core_get_status_sql(); 602 604 $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}" ); -
trunk/tests/phpunit/testcases/blogs/cache.php
r9139 r9231 232 232 $this->set_current_user( $old_user ); 233 233 } 234 235 /** 236 * @group bp_blogs_total_blogs 237 * @group counts 238 */ 239 public function test_bp_blogs_total_count_should_respect_cached_value_of_0() { 240 if ( ! is_multisite() ) { 241 return; 242 } 243 244 global $wpdb; 245 246 // prime cache 247 // no blogs are created by default, so count is zero 248 bp_blogs_total_blogs(); 249 $first_query_count = $wpdb->num_queries; 250 251 // run function again 252 bp_blogs_total_blogs(); 253 254 // check if function references cache or hits the DB by comparing query count 255 $this->assertEquals( $first_query_count, $wpdb->num_queries ); 256 } 234 257 } -
trunk/tests/phpunit/testcases/groups/cache.php
r9156 r9231 201 201 $this->assertEquals( 2, count( groups_get_group_admins( $g ) ) ); 202 202 } 203 204 /** 205 * @group groups_get_total_group_count 206 * @group counts 207 */ 208 public function test_groups_get_total_group_count_should_respect_cached_value_of_0() { 209 global $wpdb; 210 211 // prime cache 212 // no groups are created by default, so count is zero 213 groups_get_total_group_count(); 214 $first_query_count = $wpdb->num_queries; 215 216 // run function again 217 groups_get_total_group_count(); 218 219 // check if function references cache or hits the DB by comparing query count 220 $this->assertEquals( $first_query_count, $wpdb->num_queries ); 221 } 203 222 }
Note: See TracChangeset
for help on using the changeset viewer.