Skip to:
Content

bbPress.org

Changeset 7257


Ignore:
Timestamp:
06/23/2024 09:09:20 PM (19 months ago)
Author:
johnjamesjacoby
Message:

Roles: prevent notices when calling bbp_add_forums_roles()

This change adds sanity checks around the $wp_roles parameter of the bbp_add_forums_roles() function.

It will now attempt to initialize the WP_Roles class just-in-time, but only if not already doing the wp_roles_init action (to prevent recursion).

If after all of that $wp_roles is still not what it needs to be, this function will now silently bail instead of proceeding (to prevent debug notices & errors).

Fixes #3493.

Props naxoc.

In branches/2.6, for 2.6.10.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/core/capabilities.php

    r6777 r7257  
    286286function bbp_add_forums_roles( $wp_roles = null ) {
    287287
     288    // Maybe initialize WP_Roles just-in-time, but
     289    if ( empty( $wp_roles ) && ! doing_action( 'wp_roles_init' ) ) {
     290        $wp_roles = wp_roles();
     291    }
     292
     293    // Bail if unexpected param type
     294    if ( ! is_a( $wp_roles, 'WP_Roles' ) ) {
     295        return;
     296    }
     297
    288298    // Get the dynamic roles
    289299    $bbp_roles = bbp_get_dynamic_roles();
Note: See TracChangeset for help on using the changeset viewer.