Skip to:
Content

BuddyPress.org

Changeset 10853


Ignore:
Timestamp:
06/01/2016 04:59:31 PM (9 years ago)
Author:
r-a-y
Message:

Activity: Cast activity properties as integers where appropriate.

Props DJPaul, r-a-y.

See #6977.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-admin.php

    r10828 r10853  
    580580        // If an error occurred, pass back the activity ID that failed.
    581581        if ( $error )
    582             $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
     582            $redirect_to = add_query_arg( 'error', $error, $redirect_to );
    583583        else
    584             $redirect_to = add_query_arg( 'updated', (int) $activity->id, $redirect_to );
     584            $redirect_to = add_query_arg( 'updated', $activity->id, $redirect_to );
    585585
    586586        /**
  • trunk/src/bp-activity/bp-activity-embeds.php

    r10852 r10853  
    104104
    105105        // No need to requery if we already got the embed activity
    106         if ( (int) $activity_id === (int) $activity->id ) {
     106        if ( (int) $activity_id === $activity->id ) {
    107107            return $activities_template->has_activities();
    108108        }
  • trunk/src/bp-activity/bp-activity-functions.php

    r10833 r10853  
    170170
    171171    // Get activity object.
    172     $activity  = new BP_Activity_Activity( (int) $activity_id );
     172    $activity  = new BP_Activity_Activity( $activity_id );
    173173
    174174    // Try to find mentions.
     
    25572557
    25582558    // Check to see if the parent activity is hidden, and if so, hide this comment publicly.
    2559     $is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
     2559    $is_hidden = $activity->hide_sitewide ? 1 : 0;
    25602560
    25612561    /**
  • trunk/src/bp-activity/bp-activity-screens.php

    r10828 r10853  
    282282            $url = sprintf(
    283283                site_url( 'wp-login.php?redirect_to=%s' ),
    284                 urlencode( esc_url_raw( bp_activity_get_permalink( (int) bp_current_action() ) ) )
     284                urlencode( esc_url_raw( bp_activity_get_permalink( bp_current_action() ) ) )
    285285            );
    286286        }
  • trunk/src/bp-activity/bp-activity-template.php

    r10825 r10853  
    15641564        // quite powerful, because doing so also deletes all comments to that
    15651565        // activity item. We should revisit this eventually.
    1566         if ( isset( $activity->user_id ) && ( (int) $activity->user_id === bp_loggedin_user_id() ) ) {
     1566        if ( isset( $activity->user_id ) && ( $activity->user_id === bp_loggedin_user_id() ) ) {
    15671567            $can_delete = true;
    15681568        }
     
    16171617
    16181618        // Get the ID of the parent activity content.
    1619         $parent_id = (int) $activities_template->activity->item_id;
     1619        $parent_id = $activities_template->activity->item_id;
    16201620
    16211621        // Bail if no parent content.
     
    16811681
    16821682        // Get the ID of the parent activity content.
    1683         $parent_id = (int) $activities_template->activity->item_id;
     1683        $parent_id = $activities_template->activity->item_id;
    16841684
    16851685        // Bail if no parent item.
  • trunk/src/bp-activity/classes/class-bp-activity-activity.php

    r10588 r10853  
    108108     * @var int
    109109     */
    110     var $hide_sitewide = false;
     110    var $hide_sitewide = 0;
    111111
    112112    /**
     
    143143    public function __construct( $id = false ) {
    144144        if ( !empty( $id ) ) {
    145             $this->id = $id;
     145            $this->id = (int) $id;
    146146            $this->populate();
    147147        }
     
    176176            $this->content           = $row->content;
    177177            $this->date_recorded     = $row->date_recorded;
    178             $this->hide_sitewide     = $row->hide_sitewide;
     178            $this->hide_sitewide     = (int) $row->hide_sitewide;
    179179            $this->mptt_left         = (int) $row->mptt_left;
    180180            $this->mptt_right        = (int) $row->mptt_right;
    181             $this->is_spam           = $row->is_spam;
     181            $this->is_spam           = (int) $row->is_spam;
    182182        }
    183183
     
    709709        // Now fetch data from the cache.
    710710        foreach ( $activity_ids as $activity_id ) {
    711             $activities[] = wp_cache_get( $activity_id, 'bp_activity' );
     711            // Integer casting.
     712            $activity = wp_cache_get( $activity_id, 'bp_activity' );
     713            if ( ! empty( $activity ) ) {
     714                $activity->id                = (int) $activity->id;
     715                $activity->user_id           = (int) $activity->user_id;
     716                $activity->item_id           = (int) $activity->item_id;
     717                $activity->secondary_item_id = (int) $activity->secondary_item_id;
     718                $activity->hide_sitewide     = (int) $activity->hide_sitewide;
     719                $activity->mptt_left         = (int) $activity->mptt_left;
     720                $activity->mptt_right        = (int) $activity->mptt_right;
     721                $activity->is_spam           = (int) $activity->is_spam;
     722            }
     723
     724            $activities[] = $activity;
    712725        }
    713726
     
    10721085        if ( ! empty( $where_args ) ) {
    10731086            $where_sql = 'WHERE ' . join( ' AND ', $where_args );
    1074             return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
     1087            $result = $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
     1088
     1089            return is_numeric( $result ) ? (int) $result : false;
    10751090        }
    10761091
     
    17641779        $bp = buddypress();
    17651780
    1766         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
     1781        $result = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
     1782
     1783        return is_numeric( $result ) ? (int) $result : false;
    17671784    }
    17681785
  • trunk/src/bp-blogs/bp-blogs-activity.php

    r10731 r10853  
    949949    remove_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment',          10, 4 );
    950950
    951     if ( 1 === (int) $activity->is_spam && 'spam' !== $post_comment_status ) {
     951    if ( 1 === $activity->is_spam && 'spam' !== $post_comment_status ) {
    952952        wp_spam_comment( $post_comment_id );
    953953    } elseif ( ! $activity->is_spam ) {
Note: See TracChangeset for help on using the changeset viewer.