Changeset 11851
- Timestamp:
- 02/08/2018 03:20:59 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-cache.php
r10401 r11851 44 44 function bp_notifications_clear_all_for_user_cache( $user_id = 0 ) { 45 45 wp_cache_delete( 'all_for_user_' . $user_id, 'bp_notifications' ); 46 wp_cache_delete( $user_id, 'bp_notifications_unread_count' ); 46 47 } 47 48 -
trunk/src/bp-notifications/bp-notifications-functions.php
r11447 r11851 608 608 */ 609 609 function bp_notifications_get_unread_notification_count( $user_id = 0 ) { 610 $notifications = bp_notifications_get_all_notifications_for_user( $user_id ); 611 $count = ! empty( $notifications ) ? count( $notifications ) : 0; 610 if ( empty( $user_id ) ) { 611 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); 612 } 613 614 $count = wp_cache_get( $user_id, 'bp_notifications_unread_count' ); 615 if ( false === $count ) { 616 $count = BP_Notifications_Notification::get_total_count( array( 617 'user_id' => $user_id, 618 'is_new' => true, 619 ) ); 620 wp_cache_set( $user_id, $count, 'bp_notifications_unread_count' ); 621 } 612 622 613 623 /** -
trunk/tests/phpunit/testcases/notifications/functions.php
r11737 r11851 36 36 37 37 $this->assertFalse( wp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) ); 38 $this->assertFalse( wp_cache_get( $u, 'bp_notifications_unread_count' ) ); 38 39 } 39 40 … … 62 63 63 64 $this->assertFalse( wp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) ); 65 $this->assertFalse( wp_cache_get( $u, 'bp_notifications_unread_count' ) ); 64 66 } 65 67 … … 92 94 93 95 $this->assertFalse( wp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) ); 96 $this->assertFalse( wp_cache_get( $u, 'bp_notifications_unread_count' ) ); 94 97 } 95 98 … … 122 125 123 126 $this->assertFalse( wp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) ); 127 $this->assertFalse( wp_cache_get( $u, 'bp_notifications_unread_count' ) ); 124 128 } 125 129
Note: See TracChangeset
for help on using the changeset viewer.