Skip to:
Content

BuddyPress.org

Changeset 9213


Ignore:
Timestamp:
12/04/2014 08:00:17 PM (10 years ago)
Author:
boonebgorges
Message:

Don't use extract() in BP_Activity_Activity::get().

Props r-a-y.
See #5698, #4988.

File:
1 edited

Legend:

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

    r9212 r9213  
    337337        );
    338338        $r = wp_parse_args( $args, $defaults );
    339         extract( $r );
    340339
    341340        // Select conditions
     
    352351        $excluded_types = array();
    353352
     353        // Regular filtering
     354        if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
     355            $where_conditions['filter_sql'] = $filter_sql;
     356        }
     357
    354358        // Spam
    355         if ( 'ham_only' == $spam )
     359        if ( 'ham_only' == $r['spam'] ) {
    356360            $where_conditions['spam_sql'] = 'a.is_spam = 0';
    357         elseif ( 'spam_only' == $spam )
     361        } elseif ( 'spam_only' == $r['spam'] ) {
    358362            $where_conditions['spam_sql'] = 'a.is_spam = 1';
     363        }
    359364
    360365        // Searching
    361         if ( $search_terms ) {
    362             $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
     366        if ( $r['search_terms'] ) {
     367            $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
    363368            $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
    364369        }
    365370
    366         // Filtering
    367         if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) )
    368             $where_conditions['filter_sql'] = $filter_sql;
    369 
    370371        // Sorting
    371         if ( $sort != 'ASC' && $sort != 'DESC' )
     372        $sort = $r['sort'];
     373        if ( $sort != 'ASC' && $sort != 'DESC' ) {
    372374            $sort = 'DESC';
     375        }
    373376
    374377        // Hide Hidden Items?
    375         if ( !$show_hidden )
     378        if ( ! $r['show_hidden'] )
    376379            $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
    377380
    378381        // Exclude specified items
    379         if ( !empty( $exclude ) ) {
    380             $exclude = implode( ',', wp_parse_id_list( $exclude ) );
     382        if ( ! empty( $r['exclude'] ) ) {
     383            $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
    381384            $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
    382385        }
    383386
    384387        // The specific ids to which you want to limit the query
    385         if ( !empty( $in ) ) {
    386             $in = implode( ',', wp_parse_id_list( $in ) );
     388        if ( ! empty( $r['in'] ) ) {
     389            $in = implode( ',', wp_parse_id_list( $r['in'] ) );
    387390            $where_conditions['in'] = "a.id IN ({$in})";
    388391        }
    389392
    390393        // Process meta_query into SQL
    391         $meta_query_sql = self::get_meta_query_sql( $meta_query );
     394        $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
    392395
    393396        if ( ! empty( $meta_query_sql['join'] ) ) {
     
    400403
    401404        // Process date_query into SQL
    402         $date_query_sql = self::get_date_query_sql( $date_query );
     405        $date_query_sql = self::get_date_query_sql( $r['date_query'] );
    403406
    404407        if ( ! empty( $date_query_sql ) ) {
     
    409412        // comments in the stream like normal comments or threaded below
    410413        // the activity.
    411         if ( false === $display_comments || 'threaded' === $display_comments ) {
     414        if ( false === $r['display_comments'] || 'threaded' === $r['display_comments'] ) {
    412415            $excluded_types[] = 'activity_comment';
    413416        }
     
    415418        // Exclude 'last_activity' items unless the 'action' filter has
    416419        // been explicitly set
    417         if ( empty( $filter['object'] ) ) {
     420        if ( empty( $r['filter']['object'] ) ) {
    418421            $excluded_types[] = 'last_activity';
    419422        }
     
    469472
    470473        // Sanitize page and per_page parameters
    471         $page     = absint( $page     );
    472         $per_page = absint( $per_page );
     474        $page     = absint( $r['page']     );
     475        $per_page = absint( $r['per_page'] );
    473476
    474477        $retval = array(
     
    560563        }
    561564
    562         if ( ! empty( $activity_ids ) && $update_meta_cache ) {
     565        if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
    563566            bp_activity_update_meta_cache( $activity_ids );
    564567        }
    565568
    566         if ( $activities && $display_comments )
    567             $activities = BP_Activity_Activity::append_comments( $activities, $spam );
     569        if ( $activities && $r['display_comments'] ) {
     570            $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
     571        }
    568572
    569573        // Pre-fetch data associated with activity users and other objects
     
    590594            $total_activities     = $wpdb->get_var( $total_activities_sql );
    591595
    592             if ( !empty( $max ) ) {
    593                 if ( (int) $total_activities > (int) $max )
    594                     $total_activities = $max;
     596            if ( !empty( $r['max'] ) ) {
     597                if ( (int) $total_activities > (int) $r['max'] )
     598                    $total_activities = $r['max'];
    595599            }
    596600
Note: See TracChangeset for help on using the changeset viewer.