Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/19/2015 09:07:23 PM (7 years ago)
Author:
johnjamesjacoby
Message:

In BP_Activity_Activity::get_scope_query_sql() remove unused variable and add more strict comparisons to $scopes to ensure parsing of correct variable types. See #5891.

File:
1 edited

Legend:

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

    r9379 r9380  
    860860     * @since BuddyPress (2.2.0)
    861861     *
    862      * @param  string $scope The activity scope
    863      * @param  array  $r     Current activity arguments. Same as those of BP_Activity_Activity::get(),
     862     * @param  mixed $scope  The activity scope. Accepts string or array of scopes
     863     * @param  array $r      Current activity arguments. Same as those of BP_Activity_Activity::get(),
    864864     *                       but merged with defaults.
    865865     * @return array 'sql' WHERE SQL string and 'override' activity args
    866866     */
    867     public static function get_scope_query_sql( $scope = '', $r = array() ) {
     867    public static function get_scope_query_sql( $scope = false, $r = array() ) {
     868
     869        // Define arrays for future use
    868870        $query_args = array();
    869871        $override   = array();
    870872        $retval     = array();
    871873
    872         if ( ! is_array( $scope ) ) {
     874        // Check for array of scopes
     875        if ( is_array( $scope ) ) {
     876            $scopes = $scope;
     877
     878        // Explode a comma separated string of scopes
     879        } elseif ( is_string( $scope ) ) {
    873880            $scopes = explode( ',', $scope );
    874         } else {
    875             $scopes = $scope;
    876         }
    877 
     881        }
     882
     883        // Bail if no scope passed
    878884        if ( empty( $scopes ) ) {
    879             return $sql;
    880         }
    881 
    882         // helper to easily grab the 'user_id'
     885            return false;
     886        }
     887
     888        // Helper to easily grab the 'user_id'
    883889        if ( ! empty( $r['filter']['user_id'] ) ) {
    884890            $r['user_id'] = $r['filter']['user_id'];
Note: See TracChangeset for help on using the changeset viewer.