Skip to:
Content

BuddyPress.org

Ticket #6977: 6977.02.patch

File 6977.02.patch, 11.3 KB (added by r-a-y, 9 years ago)
  • src/bp-blogs/classes/class-bp-blogs-blog.php

     
    4848         */
    4949        public function __construct( $id = null ) {
    5050                if ( !empty( $id ) ) {
    51                         $this->id = $id;
     51                        $this->id = (int) $id;
    5252                        $this->populate();
    5353                }
    5454        }
     
    6363
    6464                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
    6565
    66                 $this->user_id = $blog->user_id;
    67                 $this->blog_id = $blog->blog_id;
     66                $this->user_id = (int) $blog->user_id;
     67                $this->blog_id = (int) $blog->blog_id;
    6868        }
    6969
    7070        /**
  • src/bp-core/classes/class-bp-user-query.php

     
    591591                // Match up to the user ids from the main query.
    592592                foreach ( $this->user_ids as $key => $uid ) {
    593593                        if ( isset( $r[ $uid ] ) ) {
     594                                $r[ $uid ]->ID = (int) $uid;
     595                                $r[ $uid ]->user_status = (int) $r[ $uid ]->user_status;
     596
    594597                                $this->results[ $uid ] = $r[ $uid ];
    595598
    596599                                // The BP template functions expect an 'id'
    597600                                // (as opposed to 'ID') property.
    598                                 $this->results[ $uid ]->id = $uid;
     601                                $this->results[ $uid ]->id = (int) $uid;
    599602
    600603                        // Remove user ID from original user_ids property.
    601604                        } else {
  • src/bp-groups/classes/class-bp-groups-group.php

     
    208208                }
    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
    220220                // Are we getting extra group data?
     
    231231
    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;
    236240                                } else {
     
    241245                        // Set up some specific group vars from meta. Excluded
    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.
    247251                        $user_id          = bp_loggedin_user_id();
  • src/bp-groups/classes/class-bp-groups-member.php

     
    185185                $member = $wpdb->get_row($sql);
    186186
    187187                if ( !empty( $member ) ) {
    188                         $this->id            = $member->id;
    189                         $this->group_id      = $member->group_id;
    190                         $this->user_id       = $member->user_id;
    191                         $this->inviter_id    = $member->inviter_id;
    192                         $this->is_admin      = $member->is_admin;
    193                         $this->is_mod        = $member->is_mod;
    194                         $this->is_banned     = $member->is_banned;
     188                        $this->id            = (int) $member->id;
     189                        $this->group_id      = (int) $member->group_id;
     190                        $this->user_id       = (int) $member->user_id;
     191                        $this->inviter_id    = (int) $member->inviter_id;
     192                        $this->is_admin      = (int) $member->is_admin;
     193                        $this->is_mod        = (int) $member->is_mod;
     194                        $this->is_banned     = (int) $member->is_banned;
    195195                        $this->user_title    = $member->user_title;
    196196                        $this->date_modified = $member->date_modified;
    197                         $this->is_confirmed  = $member->is_confirmed;
     197                        $this->is_confirmed  = (int) $member->is_confirmed;
    198198                        $this->comments      = $member->comments;
    199                         $this->invite_sent   = $member->invite_sent;
     199                        $this->invite_sent   = (int) $member->invite_sent;
    200200
    201201                        $this->user = new BP_Core_User( $this->user_id );
    202202                }
  • src/bp-messages/classes/class-bp-messages-message.php

     
    8888                $bp = buddypress();
    8989
    9090                if ( $message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id ) ) ) {
    91                         $this->id        = $message->id;
    92                         $this->thread_id = $message->thread_id;
    93                         $this->sender_id = $message->sender_id;
     91                        $this->id        = (int) $message->id;
     92                        $this->thread_id = (int) $message->thread_id;
     93                        $this->sender_id = (int) $message->sender_id;
    9494                        $this->subject   = $message->subject;
    9595                        $this->message   = $message->message;
    9696                        $this->date_sent = $message->date_sent;
  • src/bp-messages/classes/class-bp-messages-notice.php

     
    6262         */
    6363        public function __construct( $id = null ) {
    6464                if ( $id ) {
    65                         $this->id = $id;
     65                        $this->id = (int) $id;
    6666                        $this->populate();
    6767                }
    6868        }
     
    8585                        $this->subject   = $notice->subject;
    8686                        $this->message   = $notice->message;
    8787                        $this->date_sent = $notice->date_sent;
    88                         $this->is_active = $notice->is_active;
     88                        $this->is_active = (int) $notice->is_active;
    8989                }
    9090        }
    9191
  • src/bp-messages/classes/class-bp-messages-thread.php

     
    166166                }
    167167
    168168                $last_message_index         = count( $this->messages ) - 1;
    169                 $this->last_message_id      = $this->messages[ $last_message_index ]->id;
     169                $this->last_message_id      = (int) $this->messages[ $last_message_index ]->id;
    170170                $this->last_message_date    = $this->messages[ $last_message_index ]->date_sent;
    171                 $this->last_sender_id       = $this->messages[ $last_message_index ]->sender_id;
     171                $this->last_sender_id       = (int) $this->messages[ $last_message_index ]->sender_id;
    172172                $this->last_message_subject = $this->messages[ $last_message_index ]->subject;
    173173                $this->last_message_content = $this->messages[ $last_message_index ]->message;
    174174
    175175                foreach ( (array) $this->messages as $key => $message ) {
    176                         $this->sender_ids[ $message->sender_id ] = $message->sender_id;
     176                        $this->sender_ids[ $message->sender_id ] = (int) $message->sender_id;
    177177                }
    178178
    179179                // Fetch the recipients.
     
    181181
    182182                // Get the unread count for the logged in user.
    183183                if ( isset( $this->recipients[ $r['user_id'] ] ) ) {
    184                         $this->unread_count = $this->recipients[ $r['user_id'] ]->unread_count;
     184                        $this->unread_count = (int) $this->recipients[ $r['user_id'] ]->unread_count;
    185185                }
    186186
    187187                // Grab all message meta.
  • src/bp-notifications/classes/class-bp-notifications-notification.php

     
    9797         */
    9898        public function __construct( $id = 0 ) {
    9999                if ( ! empty( $id ) ) {
    100                         $this->id = $id;
     100                        $this->id = (int) $id;
    101101                        $this->populate();
    102102                }
    103103        }
     
    188188
    189189                // Setup the notification data.
    190190                if ( ! empty( $notification ) && ! is_wp_error( $notification ) ) {
    191                         $this->item_id           = $notification->item_id;
    192                         $this->secondary_item_id = $notification->secondary_item_id;
    193                         $this->user_id           = $notification->user_id;
     191                        $this->item_id           = (int) $notification->item_id;
     192                        $this->secondary_item_id = (int) $notification->secondary_item_id;
     193                        $this->user_id           = (int) $notification->user_id;
    194194                        $this->component_name    = $notification->component_name;
    195195                        $this->component_action  = $notification->component_action;
    196196                        $this->date_notified     = $notification->date_notified;
    197                         $this->is_new            = $notification->is_new;
     197                        $this->is_new            = (int) $notification->is_new;
    198198                }
    199199        }
    200200
  • src/bp-xprofile/classes/class-bp-xprofile-field.php

     
    260260                        $args = (array) $args;
    261261                }
    262262
     263                $int_fields = array(
     264                        'id', 'is_required', 'group_id', 'parent_id', 'is_default_option',
     265                        'field_order', 'option_order', 'can_delete'
     266                );
     267
    263268                foreach ( $args as $k => $v ) {
    264269                        if ( 'name' === $k || 'description' === $k ) {
    265270                                $v = stripslashes( $v );
    266271                        }
     272
     273                        // Cast numeric strings as integers.
     274                        if ( true === in_array( $k, $int_fields ) ) {
     275                                $v = (int) $v;
     276                        }
     277
    267278                        $this->{$k} = $v;
    268279                }
    269280
  • src/bp-xprofile/classes/class-bp-xprofile-group.php

     
    103103                $group = reset( $group );
    104104
    105105                // Set object properties.
    106                 $this->id          = $group->id;
     106                $this->id          = (int) $group->id;
    107107                $this->name        = $group->name;
    108108                $this->description = $group->description;
    109                 $this->can_delete  = $group->can_delete;
    110                 $this->group_order = $group->group_order;
     109                $this->can_delete  = (int) $group->can_delete;
     110                $this->group_order = (int) $group->group_order;
    111111        }
    112112
    113113        /**
     
    466466
    467467                // Merge the field array back in with the group array.
    468468                foreach( (array) $groups as $group ) {
     469                        $group->id          = (int) $group->id;
     470                        $group->group_order = (int) $group->group_order;
     471                        $group->can_delete  = (int) $group->can_delete;
    469472
    470473                        // Indexes may have been shifted after previous deletions, so we get a
    471474                        // fresh one each time through the loop.
  • src/bp-xprofile/classes/class-bp-xprofile-profiledata.php

     
    8888                }
    8989
    9090                if ( $profiledata ) {
    91                         $this->id           = $profiledata->id;
    92                         $this->user_id      = $profiledata->user_id;
    93                         $this->field_id     = $profiledata->field_id;
     91                        $this->id           = (int) $profiledata->id;
     92                        $this->user_id      = (int) $profiledata->user_id;
     93                        $this->field_id     = (int) $profiledata->field_id;
    9494                        $this->value        = stripslashes( $profiledata->value );
    9595                        $this->last_updated = $profiledata->last_updated;
    9696
    9797                } else {
    9898                        // When no row is found, we'll need to set these properties manually.
    99                         $this->field_id     = $field_id;
    100                         $this->user_id      = $user_id;
     99                        $this->field_id     = (int) $field_id;
     100                        $this->user_id      = (int) $user_id;
    101101                }
    102102        }
    103103