Skip to:
Content

BuddyPress.org

Opened 7 months ago

Closed 7 months ago

#9139 closed defect (bug) (fixed)

bp_is_directory_homepage() should return false when called from sub-sites

Reported by: r-a-y's profile r-a-y Owned by: imath's profile imath
Milestone: 12.5.0 Priority: normal
Severity: normal Version: 12.0.0
Component: Core Keywords: dev-feedback has-patch
Cc:

Description (last modified by r-a-y)

Hi gang,

We ran into a scenario where the Groups Directory was being displayed as the homepage on a sub-site on a multisite install.

The issue is due to the check for bp_is_directory_homepage() in each component's parse_query() method. For example, in the BP groups component, bp_is_directory_homepage() is used to determine if the group directory page ID matches the front page's ID:

When this occurs, BP sets the current_component property to groups. This works fine as intended on the root site, but this check should be omitted from sub-sites altogether since this isn't expected behavior. On our install, the sub-site's front page ID matched the Group Directory's page ID from the root site and this caused bp_is_directory_homepage() to return true causing the Group Directory to display instead of the sub-site's intended front page when bp_redirect_canonical() is disabled. (If bp_redirect_canonical() is enabled, sub-site homepages are redirected back to the root site.)

I would suggest returning false for bp_is_directory_homepage() when the function is being called from a sub-site and not the root site.

Attachments (1)

9139.01.patch (548 bytes) - added by r-a-y 7 months ago.

Download all attachments as: .zip

Change History (9)

#1 @r-a-y
7 months ago

  • Description modified (diff)

#2 @r-a-y
7 months ago

  • Description modified (diff)

#3 @imath
7 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 12.5.0

Thanks for your feedback @r-a-y

I agree with your suggestion.

#4 @boonebgorges
7 months ago

Perhaps we could consider a more general solution. Why are we running parse_query() at all on sub-sites? I think this should only be necessary when running multiblog-mode - or, what should be the same thing, when we know that BP's rewrite rules have been registered on the current site.

#5 @imath
7 months ago

Very good point @boonebgorges! I agree +1

#6 @r-a-y
7 months ago

  • Keywords has-patch added; needs-patch removed

Why are we running parse_query() at all on sub-sites? I think this should only be necessary when running multiblog-mode - or, what should be the same thing, when we know that BP's rewrite rules have been registered on the current site.

I was thinking about this myself after I posted the ticket. I think this makes the most sense. I've just attached a patch that does this.

@r-a-y
7 months ago

#7 @imath
7 months ago

In 13846:

Only parse the WP Query when needed.

On multisite configs, we don't need to parse the WP Query when loading any other site than the BP root's one.

Props r-a-y, boonebgorges

See #9139 (trunk)

#8 @imath
7 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13847:

Only parse the WP Query when needed.

On multisite configs, we don't need to parse the WP Query when loading any other site than the BP root's one.

Props r-a-y, boonebgorges

Fixes #9139 (branch 12.0)

Note: See TracTickets for help on using tickets.