Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/06/2016 06:57:41 PM (8 years ago)
Author:
r-a-y
Message:

Groups: Cast properties as integers in BP_Groups_Group::get().

See #6977.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-group.php

    r11027 r11065  
    978978         */
    979979        $total_groups_sql = apply_filters( 'bp_groups_get_total_groups_sql', $t_sql, $total_sql, $r );
    980         $total_groups     = $wpdb->get_var( $total_groups_sql );
     980        $total_groups     = (int) $wpdb->get_var( $total_groups_sql );
    981981
    982982        $group_ids = array();
     
    993993        if ( ! empty( $r['update_meta_cache'] ) ) {
    994994            bp_groups_update_meta_cache( $group_ids );
     995        }
     996
     997        // Set up integer properties needing casting.
     998        $int_props = array(
     999            'id', 'creator_id', 'enable_forum', 'total_member_count',
     1000        );
     1001
     1002        // Integer casting.
     1003        foreach ( $paged_groups as $key => $g ) {
     1004            foreach ( $int_props as $int_prop ) {
     1005                $paged_groups[ $key ]->{$int_prop} = (int) $paged_groups[ $key ]->{$int_prop};
     1006            }
    9951007        }
    9961008
     
    14321444
    14331445        foreach ( $paged_groups as &$group ) {
    1434             $group->is_member  = groups_is_user_member( $user_id, $group->id ) ? '1' : '0';
    1435             $group->is_invited = groups_is_user_invited( $user_id, $group->id ) ? '1' : '0';
    1436             $group->is_pending = groups_is_user_pending( $user_id, $group->id ) ? '1' : '0';
     1446            $group->is_member  = groups_is_user_member( $user_id, $group->id )  ? 1 : 0;
     1447            $group->is_invited = groups_is_user_invited( $user_id, $group->id ) ? 1 : 0;
     1448            $group->is_pending = groups_is_user_pending( $user_id, $group->id ) ? 1 : 0;
    14371449            $group->is_banned  = (bool) groups_is_user_banned( $user_id, $group->id );
    14381450        }
Note: See TracChangeset for help on using the changeset viewer.