Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/22/2016 10:11:20 PM (10 years ago)
Author:
r-a-y
Message:

Groups: Cast properties as integers where appropriate.

See #6977.

File:
1 edited

Legend:

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

    r10937 r11027  
    176176
    177177                if ( !empty( $id ) ) {
    178                         $this->id = $id;
     178                        $this->id = (int) $id;
    179179                        $this->populate();
    180180                }
     
    209209
    210210                // Group found so setup the object variables.
    211                 $this->id           = $group->id;
    212                 $this->creator_id   = $group->creator_id;
     211                $this->id           = (int) $group->id;
     212                $this->creator_id   = (int) $group->creator_id;
    213213                $this->name         = stripslashes( $group->name );
    214214                $this->slug         = $group->slug;
    215215                $this->description  = stripslashes( $group->description );
    216216                $this->status       = $group->status;
    217                 $this->enable_forum = $group->enable_forum;
     217                $this->enable_forum = (int) $group->enable_forum;
    218218                $this->date_created = $group->date_created;
    219219
     
    232232                        // Add admins and moderators to their respective arrays.
    233233                        foreach ( (array) $admin_mods as $user ) {
     234                                $user->user_id  = (int) $user->user_id;
     235                                $user->is_admin = (int) $user->is_admin;
     236                                $user->is_mod   = (int) $user->is_mod;
     237
    234238                                if ( !empty( $user->is_admin ) ) {
    235239                                        $this->admins[] = $user;
     
    242246                        // from the bp_groups cache because it's cached independently.
    243247                        $this->last_activity      = groups_get_groupmeta( $this->id, 'last_activity' );
    244                         $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
     248                        $this->total_member_count = (int) groups_get_groupmeta( $this->id, 'total_member_count' );
    245249
    246250                        // Set user-specific data.
     
    436440         * @param string|bool $table_name Optional. Name of the table to check
    437441         *                                against. Default: $bp->groups->table_name.
    438          * @return string|null ID of the group, if one is found, else null.
     442         * @return int|null Group ID if found; null if not.
    439443         */
    440444        public static function group_exists( $slug, $table_name = false ) {
     
    447451                        return false;
    448452
    449                 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", strtolower( $slug ) ) );
     453                $query = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", strtolower( $slug ) ) );
     454
     455                return is_numeric( $query ) ? (int) $query : $query;
    450456        }
    451457
Note: See TracChangeset for help on using the changeset viewer.