Skip to:
Content

bbPress.org

Opened 7 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#3694 closed defect (bug) (fixed)

Irrelevant database queries occurring in `BBP_Forums_Group_Extension::map_group_forum_meta_caps()` method

Reported by: r-a-y Owned by: johnjamesjacoby
Priority: normal Milestone: 2.6.20
Component: Extend - BuddyPress Version: 2.6.18
Severity: normal Keywords: has-patch
Cc: r-a-y, emaralive

Description

In bbPress 2.6.18, there was a change to the BBP_Forums_Group_Extension::map_group_forum_meta_caps() method to check the post type before the capability check:
​https://github.com/bbpress/bbPress/blame/2.6/src/includes/extend/buddypress/groups.php#L405-L441

The problem here is the post type checks take place before the capability check, so this method can run unnecessarily for other non-bbPress capabilities. This currently causes a @SELECT *
FROM wp_1_posts WHERE ID = 1 LIMIT 1@ database query to occur for each cap check that passes through the 'map_meta_cap' filter. On our BuddyPress install, about 15 of these database queries take place.

Attached patch adds a simple cap check against the caps checked inside the map_group_forum_meta_caps() method to address this issue.

Attachments (1)

3694.01.patch​ (922 bytes ) - added by r-a-y 7 weeks ago.

Download all attachments as: .zip

Change History (4)

#1 @emaralive
7 weeks ago

  • Cc emaralive added

#2 @johnjamesjacoby
5 weeks ago

  • Owner set to johnjamesjacoby
  • Resolution → fixed
  • Status new → closed

In 7829:

BuddyPress: Avoid unrelated capability queries.

Check for group forum capabilities before looking up the object post type. This avoids unnecessary database queries during unrelated capability checks while preserving the existing capability filter.

Add regression coverage for the skipped query and filtered return value.

In branches/2.6, for 2.6.20.

Props r-a-y.
Fixes #3694.

#3 @johnjamesjacoby
5 weeks ago

  • Milestone Awaiting Review → 2.6.20
Note: See TracTickets for help on using tickets.