Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/22/2016 10:32:06 PM (8 years ago)
Author:
r-a-y
Message:

Messages: Cast properties as integers where appropriate.

See #6977.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/classes/class-bp-messages-message.php

    r10421 r11028  
    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;
     
    221221        $bp = buddypress();
    222222
    223         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND thread_id = %d ORDER BY date_sent DESC LIMIT 1", bp_loggedin_user_id(), $thread_id ) );
     223        $query = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND thread_id = %d ORDER BY date_sent DESC LIMIT 1", bp_loggedin_user_id(), $thread_id ) );
     224
     225        return is_numeric( $query ) ? (int) $query : $query;
    224226    }
    225227
     
    237239        $bp = buddypress();
    238240
    239         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) );
     241        $query = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) );
     242
     243        return is_numeric( $query ) ? (int) $query : $query;
    240244    }
    241245
     
    251255        $bp = buddypress();
    252256
    253         return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );
     257        $query = $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );
     258
     259        return is_numeric( $query ) ? (int) $query : $query;
    254260    }
    255261}
Note: See TracChangeset for help on using the changeset viewer.