[buddypress-trac] [BuddyPress Trac] #9139: bp_is_directory_homepage() should return false when called from sub-sites

buddypress-trac noreply at wordpress.org
Sun Apr 28 17:21:08 UTC 2024


#9139: bp_is_directory_homepage() should return false when called from sub-sites
--------------------------+------------------------------
 Reporter:  r-a-y         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Core          |     Version:  12.0.0
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |
--------------------------+------------------------------
Description changed by r-a-y:

Old description:

> 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.
>
> 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.

New description:

 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.

--

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9139#comment:1>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list