Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#5812 closed defect (bug) (fixed)

BP_Group_Extension::_register() should only run if there is a valid group ID

Reported by: r-a-y's profile r-a-y Owned by: r-a-y's profile r-a-y
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Groups Keywords: has-patch
Cc:

Description

In #4785 some work was done to overhaul the access and visibility control for group tabs.

However, if there is no group ID, BP_Group_Extension::_register() should not continue as it runs a few DB queries to check access and visibility.

To test, navigate to a user page and check the queries that are run.

Attachments (1)

5812.01.patch (664 bytes) - added by r-a-y 10 years ago.

Download all attachments as: .zip

Change History (6)

@r-a-y
10 years ago

#1 @r-a-y
10 years ago

  • Component changed from Core to Groups

01.patch bails out of the BP_Group_Extension::_register() method if there is no valid group ID. I'm hoping there aren't any unforeseen issues with doing this.

Last edited 10 years ago by r-a-y (previous) (diff)

#2 @boonebgorges
10 years ago

I doubt there will be unforeseen issues, but it's possible - there may be plugins that analyze the available BP_Group_Extension extension on each pageload, and leaving them half-initialized could be a problem for them.

A more conservative approach is to bail at the beginning of user_meets_access_condition() if $this->group_id is empty. Will that take care of the db queries?

#3 @r-a-y
10 years ago

A more conservative approach is to bail at the beginning of user_meets_access_condition() if $this->group_id is empty. Will that take care of the db queries?

Yup, that works. However, there is a backward compatibility block before that, which does a groups_get_group() call. (It doesn't run for me at the moment, but just wanted to list that.)

Could the group ID check go at the very beginning of the setup_access_settings() method?

Last edited 10 years ago by r-a-y (previous) (diff)

#4 @boonebgorges
10 years ago

Yup, let's go with that. Thanks, r-a-y!

#5 @r-a-y
10 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 8827:

Do not process BP_Group_Extension::setup_access_settings() if no group ID is available.

If no group ID is available, the BP_Group_Extension::setup_access_settings()
method should not do its checks. This is to avoid running DB queries
unnecessarily. (See #4785.)

Fixes #5812.

Note: See TracTickets for help on using tickets.