Skip to:
Content

BuddyPress.org

Changeset 11029


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

Notifications: Cast properties as integers where appropriate.

See #6977.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/classes/class-bp-notifications-notification.php

    r11015 r11029  
    9898        public function __construct( $id = 0 ) {
    9999                if ( ! empty( $id ) ) {
    100                         $this->id = $id;
     100                        $this->id = (int) $id;
    101101                        $this->populate();
    102102                }
    … …  
    186186                // Setup the notification data.
    187187                if ( ! empty( $notification ) && ! is_wp_error( $notification ) ) {
    188                         $this->item_id           = $notification->item_id;
    189                         $this->secondary_item_id = $notification->secondary_item_id;
    190                         $this->user_id           = $notification->user_id;
     188                        $this->item_id           = (int) $notification->item_id;
     189                        $this->secondary_item_id = (int) $notification->secondary_item_id;
     190                        $this->user_id           = (int) $notification->user_id;
    191191                        $this->component_name    = $notification->component_name;
    192192                        $this->component_action  = $notification->component_action;
    193193                        $this->date_notified     = $notification->date_notified;
    194                         $this->is_new            = $notification->is_new;
     194                        $this->is_new            = (int) $notification->is_new;
    195195                }
    196196        }
    … …  
    685685                $results = $wpdb->get_results( $sql );
    686686
     687                // Integer casting.
     688                foreach ( $results as $key => $result ) {
     689                        $results[$key]->id                = (int) $results[$key]->id;
     690                        $results[$key]->user_id           = (int) $results[$key]->user_id;
     691                        $results[$key]->item_id           = (int) $results[$key]->item_id;
     692                        $results[$key]->secondary_item_id = (int) $results[$key]->secondary_item_id;
     693                        $results[$key]->is_new            = (int) $results[$key]->is_new;
     694                }
     695
    687696                // Update meta cache.
    688697                if ( true === $r['update_meta_cache'] ) {
    … …  
    741750
    742751                // Return the queried results.
    743                 return $wpdb->get_var( $sql );
     752                return (int) $wpdb->get_var( $sql );
    744753        }
    745754
Note: See TracChangeset for help on using the changeset viewer.