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 | Owned by: | 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 )
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:
- https://github.com/buddypress/buddypress/blob/9df9764d33b34bf3cf2f48368741875b43250201/src/bp-groups/classes/class-bp-groups-component.php#L1067-L1074
- https://github.com/buddypress/buddypress/blob/9df9764d33b34bf3cf2f48368741875b43250201/src/bp-core/bp-core-functions.php#L1022-L1024
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)
Change History (9)
#4
@
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.
#6
@
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.
Thanks for your feedback @r-a-y
I agree with your suggestion.