Skip to:
Content

bbPress.org

Changeset 6406


Ignore:
Timestamp:
04/27/2017 05:08:05 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Moderators: Performance optimization in bbp_is_user_forum_moderator().

Rather than query for all forums a user can moderate, query for the users that can moderate the forum. This data is likely already hot in the meta-data cache from forums being loaded previously, and eliminates the need to query for forum IDs that are unrelated to the one being checked.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/forums/capabilities.php

    r6384 r6406  
    257257    if ( bbp_allow_forum_mods() ) {
    258258
    259         // Get forums the user can moderate.
    260         $forum_ids = bbp_get_moderator_forum_ids( $user_id );
    261 
    262         // Is this forum ID in the users array of forum IDs?
    263         if ( ! empty( $forum_ids ) ) {
    264             $retval = in_array( $forum_id, $forum_ids );
     259        // Get users who can moderate this forum.
     260        $user_ids = bbp_get_moderator_ids( $forum_id );
     261
     262        // Is this user ID in the users array?
     263        if ( ! empty( $user_ids ) ) {
     264            $retval = in_array( $user_id, $user_ids, true );
    265265        }
    266266    }
Note: See TracChangeset for help on using the changeset viewer.