Changeset 11086
- Timestamp:
- 09/13/2016 02:59:45 AM (10 years ago)
- Location:
- trunk/src/bp-groups
- Files:
-
- 5 edited
-
bp-groups-functions.php (modified) (3 diffs)
-
bp-groups-template.php (modified) (4 diffs)
-
classes/class-bp-groups-group.php (modified) (4 diffs)
-
classes/class-bp-groups-member.php (modified) (2 diffs)
-
classes/class-bp-groups-template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-functions.php
r11046 r11086 685 685 * @since 1.2.0 686 686 * @since 2.6.0 Added `$group_type`, `$group_type__in`, and `$group_type__not_in` parameters. 687 * @since 2.7.0 Added `$update_admin_cache` parameter. 687 688 * 688 689 * @param array|string $args { … … 714 715 'populate_extras' => true, // Fetch meta such as is_banned and is_member. 715 716 'update_meta_cache' => true, // Pre-fetch groupmeta for queried groups. 717 'update_admin_cache' => false, 716 718 ); 717 719 … … 733 735 'populate_extras' => $r['populate_extras'], 734 736 'update_meta_cache' => $r['update_meta_cache'], 737 'update_admin_cache' => $r['update_admin_cache'], 735 738 'order' => $r['order'], 736 739 'orderby' => $r['orderby'], -
trunk/src/bp-groups/bp-groups-template.php
r11035 r11086 104 104 * @since 1.0.0 105 105 * @since 2.6.0 Added `$group_type`, `$group_type__in`, and `$group_type__not_in` parameters. 106 * @since 2.7.0 Added `$update_admin_cache` parameter. 106 107 * 107 108 * @param array|string $args { … … 139 140 * the listed groups. Default: false. 140 141 * @type bool $update_meta_cache Whether to fetch groupmeta for queried groups. Default: true. 142 * @type bool $update_admin_cache Whether to pre-fetch group admins for queried groups. 143 * Defaults to true when on a group directory, where this 144 * information is needed in the loop. Otherwise false. 141 145 * } 142 146 * @return bool True if there are groups to display that match the params … … 201 205 'populate_extras' => true, 202 206 'update_meta_cache' => true, 207 'update_admin_cache' => bp_is_groups_directory() || bp_is_user_groups(), 203 208 ), 'has_groups' ); 204 209 … … 224 229 'populate_extras' => (bool) $r['populate_extras'], 225 230 'update_meta_cache' => (bool) $r['update_meta_cache'], 231 'update_admin_cache' => (bool) $r['update_admin_cache'], 226 232 ) ); 227 233 -
trunk/src/bp-groups/classes/class-bp-groups-group.php
r11072 r11086 729 729 * @since 1.6.0 730 730 * @since 2.6.0 Added `$group_type`, `$group_type__in`, and `$group_type__not_in` parameters. 731 * @since 2.7.0 Added `$update_admin_cache` parameter. 731 732 * 732 733 * @param array $args { … … 761 762 * @type bool $update_meta_cache Whether to pre-fetch groupmeta for the returned groups. 762 763 * Default: true. 764 * @type bool $update_admin_cache Whether to pre-fetch administrator IDs for the returned 765 * groups. Default: false. 763 766 * @type bool $show_hidden Whether to include hidden groups in results. Default: false. 764 767 * } … … 808 811 'populate_extras' => true, 809 812 'update_meta_cache' => true, 813 'update_admin_cache' => false, 810 814 'exclude' => false, 811 815 'show_hidden' => false, … … 1022 1026 if ( ! empty( $r['update_meta_cache'] ) ) { 1023 1027 bp_groups_update_meta_cache( $group_ids ); 1028 } 1029 1030 // Prefetch all administrator IDs, if requested. 1031 if ( $r['update_admin_cache'] ) { 1032 BP_Groups_Member::prime_group_administrator_ids_cache( $group_ids ); 1024 1033 } 1025 1034 -
trunk/src/bp-groups/classes/class-bp-groups-member.php
r11032 r11086 1044 1044 1045 1045 if ( false === $group_admins ) { 1046 $bp = buddypress(); 1047 $group_admins = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) ); 1048 1049 wp_cache_set( $group_id, $group_admins, 'bp_group_admins' ); 1046 self::prime_group_administrator_ids_cache( array( $group_id ) ); 1047 $group_admins = wp_cache_get( $group_id, 'bp_group_admins' ); 1050 1048 } 1051 1049 … … 1056 1054 1057 1055 return $group_admins; 1056 } 1057 1058 /** 1059 * Prime the bp_group_admins cache for one or more groups. 1060 * 1061 * @since 2.7.0 1062 * 1063 * @param array $group_ids IDs of the groups. 1064 * @return bool True on success. 1065 */ 1066 public static function prime_group_administrator_ids_cache( $group_ids ) { 1067 global $wpdb; 1068 1069 $uncached = bp_get_non_cached_ids( $group_ids, 'bp_group_admins' ); 1070 1071 if ( $uncached ) { 1072 $bp = buddypress(); 1073 $uncached_sql = implode( ',', array_map( 'intval', $uncached ) ); 1074 $group_admins = $wpdb->get_results( "SELECT user_id, group_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id IN ({$uncached_sql}) AND is_admin = 1 AND is_banned = 0" ); 1075 1076 $groups = array(); 1077 if ( $group_admins ) { 1078 foreach ( $group_admins as $group_admin ) { 1079 $admin_obj = new stdClass(); 1080 $admin_obj->user_id = $group_admin->user_id; 1081 $admin_obj->date_modified = $group_admin->date_modified; 1082 $groups[ $group_admin->group_id ][] = $admin_obj; 1083 } 1084 1085 foreach ( $groups as $this_group_id => $this_group_admins ) { 1086 wp_cache_set( $this_group_id, $this_group_admins, 'bp_group_admins' ); 1087 } 1088 } 1089 } 1058 1090 } 1059 1091 -
trunk/src/bp-groups/classes/class-bp-groups-template.php
r10767 r11086 173 173 'populate_extras' => true, 174 174 'update_meta_cache' => true, 175 'update_admin_cache' => false, 175 176 ); 176 177 … … 229 230 'populate_extras' => $populate_extras, 230 231 'update_meta_cache' => $update_meta_cache, 232 'update_admin_cache' => $update_admin_cache, 231 233 'show_hidden' => $show_hidden, 232 234 ) );
Note: See TracChangeset
for help on using the changeset viewer.