Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/23/2017 01:39:31 PM (8 years ago)
Author:
dcavins
Message:

Handle missing parameter in group admin fetching functions.

In some situations, bp_group_has_moderators() is
being called without a $group parameter, causing the
downstream functions problems. This commit adds an
early return if the required parameter isn’t supplied.
It also recognizes when the cache request returns false
and skips the integer casting step.

Fixes #7524.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-member.php

    r11447 r11609  
    10891089        global $wpdb;
    10901090
     1091        if ( empty( $group_id ) ) {
     1092            return array();
     1093        }
     1094
    10911095        $group_admins = wp_cache_get( $group_id, 'bp_group_admins' );
    10921096
     
    10961100        }
    10971101
    1098         // Integer casting.
    1099         foreach ( (array) $group_admins as $key => $data ) {
    1100             $group_admins[ $key ]->user_id = (int) $group_admins[ $key ]->user_id;
     1102        if ( false === $group_admins ) {
     1103            // The wp_cache_get is still coming up empty. Return an empty array.
     1104            $group_admins = array();
     1105        } else {
     1106            // Cast the user_id property as an integer.
     1107            foreach ( (array) $group_admins as $key => $data ) {
     1108                $group_admins[ $key ]->user_id = (int) $group_admins[ $key ]->user_id;
     1109            }
    11011110        }
    11021111
     
    11591168        global $wpdb;
    11601169
     1170        if ( empty( $group_id ) ) {
     1171            return array();
     1172        }
     1173
    11611174        $group_mods = wp_cache_get( $group_id, 'bp_group_mods' );
    11621175
     
    11661179        }
    11671180
    1168         // Integer casting.
    1169         foreach ( (array) $group_mods as $key => $data ) {
    1170             $group_mods[ $key ]->user_id = (int) $group_mods[ $key ]->user_id;
     1181        if ( false === $group_mods ) {
     1182            // The wp_cache_get is still coming up empty. Return an empty array.
     1183            $group_mods = array();
     1184        } else {
     1185            // Cast the user_id property as an integer.
     1186            foreach ( (array) $group_mods as $key => $data ) {
     1187                $group_mods[ $key ]->user_id = (int) $group_mods[ $key ]->user_id;
     1188            }
    11711189        }
    11721190
Note: See TracChangeset for help on using the changeset viewer.