#9237 closed defect (bug) (fixed)
[Site Health Info Tab] Some "Active components" are incorrect while viewing the BuddyPress panel
Reported by: | emaralive | Owned by: | emaralive |
---|---|---|---|
Milestone: | 14.2.1 | Priority: | normal |
Severity: | normal | Version: | 14.1.0 |
Component: | Administration | Keywords: | has-screenshots has-patch dev-feedback commit |
Cc: |
Description
While attempting to document the Site Health Info tab (see bp-documentation issue #4), I noticed that some of the listed Active components appear to be incorrectly labeled, as seen below and indicated by the ❌ (also see screenshot - site-health-info-bp-panel-15.0.png):.
NOTE: This can be seen while visiting site.url/wp-admin/site-health.php?tab=debug
(Tools > Site Health > Info tab) and expanding the BuddyPress panel, all available components (10) are active as set by site.url/wp-admin/options-general.php?page=bp-components
(Settings > BuddyPress > Components tab)
Active Components (10) | Notes |
---|---|
Extended Profiles | |
Settings | ❌ |
Friend Connections | |
Private Messages | |
Activity Streams | |
Notifications | |
User Groups | |
Site Directory | ❌ |
Members | |
Members Invitations | ❌ |
This anomaly appears to have been introduced in 14.0 because the following represents 12.5.1 and previous (also see screenshot - site-health-info-bp-panel-12.5.1.png):
NOTE: Although the labeling for 12.5.1 match up with the Components setting page, there are only 9 components listed when there should have been 10, i.e., the BuddyPress Core component appears to be missing.
Active Components (9) |
---|
Community Members |
Extended Profiles |
Account Settings |
Friend Connections |
Private Messaging |
Activity Streams |
Notifications |
User Groups |
Site Tracking |
Reality, at least to me, would dictate that there should be a total of 10 possible Active Components (8 are optional and 2 are required/Must-Use), as follows (additionally, see screenshot - bp_settings_components_tab.png):
Optional (8) | + | Must-Use (2) | = | All (10) |
---|---|---|---|---|
Extended Profiles | BuddyPress Core | Extended Profiles | ||
Account Settings | Community Members | Account Settings | ||
Friend Connections | Friend Connections | |||
Private Messaging | Private Messaging | |||
Activity Streams | Activity Streams | |||
Notifications | Notifications | |||
User Groups | User Groups | |||
Site Tracking | Site Tracking | |||
BuddyPress Core | ||||
Community Members |
The code that created the anomaly for 14.0 appears to be found in the file src/bp-core/admin/bp-core-admin-tools.php
around line 777 and the following is an example of this line:
$active_components = wp_list_pluck( bp_core_get_active_components( array(), 'objects' ), 'name', 'id' );
This produces the following 10 element associative array, of which some of the values are incorrect, as previously mentioned and described:
array(10) { ["xprofile"]=> string(17) "Extended Profiles" ["settings"]=> string(8) "Settings" ["friends"]=> string(18) "Friend Connections" ["messages"]=> string(16) "Private Messages" ["activity"]=> string(16) "Activity Streams" ["notifications"]=> string(13) "Notifications" ["groups"]=> string(11) "User Groups" ["blogs"]=> string(14) "Site Directory" ["members"]=> string(7) "Members" ["members_invitations"]=> string(19) "Members Invitations" }
For 12.5.1 a somewhat equivalent statement is as follows:
$active_components = array_intersect_key( bp_core_get_components(), buddypress()->active_components );
This produces a 9 element associative array that is processed further downstream to produce an intermediate associative array as follows:
array(9) { ["members"]=> string(17) "Community Members" ["xprofile"]=> string(17) "Extended Profiles" ["settings"]=> string(16) "Account Settings" ["friends"]=> string(18) "Friend Connections" ["messages"]=> string(17) "Private Messaging" ["activity"]=> string(16) "Activity Streams" ["notifications"]=> string(13) "Notifications" ["groups"]=> string(11) "User Groups" ["blogs"]=> string(13) "Site Tracking" }
Although, the labeling matches what appears to be standard for pre 14.0, the downside is that there are only 9 components indicated when there should be 10. What's missing is the BuddyPress Core component, just to reiterate what has been previously mentioned and described.
Since this ticket is only addressing a regression that was introduced in 14.0 (12.5.1 was only indicated/described to represent a contrast/comparison), a solution to the anomaly is represented by the submitted patch, albeit, there are a number of ways to provide a remedy. That stated the patch looks like the following, i.e., replacing line 777 with:
$all_components = array_merge( buddypress()->optional_components, buddypress()->required_components ); $active_components = array_flip( array_diff( $all_components, buddypress()->deactivated_components ) ); $active_components = wp_list_pluck( array_intersect_key( bp_core_get_components(), $active_components ), 'title' );
This produces the following array, when all components are "active" (enabled):
array(10) { ["core"]=> string(15) "BuddyPress Core" ["members"]=> string(17) "Community Members" ["xprofile"]=> string(17) "Extended Profiles" ["settings"]=> string(16) "Account Settings" ["friends"]=> string(18) "Friend Connections" ["messages"]=> string(17) "Private Messaging" ["activity"]=> string(16) "Activity Streams" ["notifications"]=> string(13) "Notifications" ["groups"]=> string(11) "User Groups" ["blogs"]=> string(13) "Site Tracking" }
The proposed patch produces the results (10 active components) as can be seen by screenshot - site-health-info-bp-panel-patch.png or any combination of "Active" components as set by the BuddyPress Settings Components tab.
Attachments (7)
Change History (21)
#1
@
7 weeks ago
Hi @emaralive
Good catch!!
Thanks a lot for this very detailed explanation. The members_invitations
entry is not a component but a component's feature, it's a downside of using the BP Component class to be sure to generate the customizable slugs. I've been working on a new BP Component Feature class to avoid this in #9098.
I think I changed the way to get active components to be sure to list the one that could be added by BP Add-ons like BP Attachments.
I'm wondering: should we list there only built-in active components or any possible active components (including the ones generated by BP Add-ons or third party plugins) ?
I believe your current patch would only list built-in components.
#2
@
7 weeks ago
I'm wondering: should we list there only built-in active components or any possible active components (including the ones generated by BP Add-ons or third party plugins) ?
Maybe built-in active components and BP add-ons. I think since it is a BuddyPress pannel. And it'd be odd to have Renato's custom add-on there when it is not a BuddyPress core add-on.
#3
@
7 weeks ago
@imath, correct about the patch only listing the built-in components, i.e., assuming the list was reflective/indicative of the Components Settings tab/page (site.url/wp-admin/options-general.php?page=bp-components
), which seemed to have been the standard, prior to 14.0.
That stated, @espellcaste brings up a very good point about how to distinguish between who is who in the list of registered components. Another example is that RTMedia registers 2 components:
- rt_comment_notifier
- rt_like_notifier
As it stands, these would not be "pretty" labels and one would have to know that these components were created by RTMedia, to make sense of these components. TBH, I was trying to keep this as simple and controllable as possible and I've not looked at #9098 to see what you have done there.
Sooooooo, to answer your question about BP add-ons & 3rd party plugins would require me to look at #9098, which I was trying to avoid in an attempt to focus on the documentation tasks I've assigned myself, thus I'll have to get back to you when I can intelligently (or somewhat intelligently) answer your question regarding BP add-ons and 3rd party plugins.
#4
@
7 weeks ago
@imath
cc: @espellcaste
I had BP Attachments installed on one of my local sites and activated it to observe the "active_components".
- buddypress()->optional_components - doesn't get updated with Attachments component info.
- buddypress()->deactivated_components - doesn't get updated when the Attachment component is disabled via BP Settings components tab.
Without getting into the minutiae, what will work is the following, due to the way BP Attachments is adding itself as an optional component:
$all_components = array_merge( bp_core_get_components( 'required' ), bp_core_get_components( 'optional' ) ); $active_components = array_merge( buddypress()->active_components, array( 'core' => '1' ) ); $active_components = wp_list_pluck( array_intersect_key( $all_components, $active_components ), 'title' );
This produces an associative array that includes the Attachments component if active/enabled, the following is when active:
array(11) { ["core"]=> string(15) "BuddyPress Core" ["members"]=> string(17) "Community Members" ["xprofile"]=> string(17) "Extended Profiles" ["settings"]=> string(16) "Account Settings" ["friends"]=> string(18) "Friend Connections" ["messages"]=> string(17) "Private Messaging" ["activity"]=> string(16) "Activity Streams" ["notifications"]=> string(13) "Notifications" ["groups"]=> string(11) "User Groups" ["blogs"]=> string(13) "Site Tracking" ["attachments"]=> string(11) "Attachments" }
I believe we should have some conversations regarding BuddyPress add-ons and how they get integrated into the component scheme of things which would help distinguish between built-in (which would include add-ons) & 3rd party (or, how 3rd party can nicely integrate into the component side of things). I'm thinking all this needs to get documented so that all players involved know what and how things should get done, i.e., the rules of engagement.
All said and done, I can upload a new patch (the example provided) which excludes 3rd party and other fluff (members-invitation) or we can discuss this further. At the moment, there are some items that I indicated that don't appear to work (the bulleted items): meaning why doesn't the BP Attachments behave like the built-in components. Plus, possibly fix the bp_attachments_get_component_info()
callback (re: BP Attachment) to also include Attachment info when the type
parameter is set to all
or, maybe, I'm mistaken and there is a reason for the way it currently returns what it returns..
Last but not least, I still need to look over #9098 to see what else might throw a monkey wrench into this "Active Component" situation.
#5
@
7 weeks ago
I believe we should have some conversations regarding BuddyPress add-ons and how they get integrated into the component scheme of things which would help distinguish between built-in (which would include add-ons) & 3rd party (or, how 3rd party can nicely integrate into the component side of things).
Got it! Agree.
My first take would be something like this:
- show core, optional or not, components at
wp-admin/options-general.php?page=bp-components
- show in a panel below it the addons (from BP core) - This could also be bundled with the core components too. But it would be good to have a visual indication they are not bundled with BuddyPress, aka, core.
- show in a panel below , the 3rd party addons (non-BP core addons).
We actually need a way to get this list of components (core, addon, etc) for the BP CLI and the REST API too.
#6
@
7 weeks ago
I added a screenshot (bp_settings_components_tab_add_on.png) as a reference point for how add-ons currently fit into the components tab. Currently there are 4 (four) BP add-ons:
BP Attachments
- BP Beta Tester
- BP Classic
- BP Search Block
And, it appears that only 1 (one) of 4 (four) registers a component and adds such as an optional component. Another place I need to check/revisit is what the Developer Handbook contains regarding components and/or add-ons.
#7
follow-up:
↓ 8
@
6 weeks ago
Thanks for looking more into it @emaralive
I personaly like this version of your patch:
$all_components = array_merge( bp_core_get_components( 'required' ), bp_core_get_components( 'optional' ) ); $active_components = array_merge( buddypress()->active_components, array( 'core' => '1' ) ); $active_components = wp_list_pluck( array_intersect_key( $all_components, $active_components ), 'title' );
I'm just wondering why not simply use bp_core_get_components()
to set $all_components
?
#8
in reply to:
↑ 7
@
6 weeks ago
@imath,
You must of missed this part:
Plus, possibly fix the bp_attachments_get_component_info() callback (re: BP Attachment) to also include Attachment info when the type parameter is set to all or, maybe, I'm mistaken and there is a reason for the way it currently returns what it returns..
Line 80 of bp-attachments/bp-attachments-loader.php
(BP Attachments add-on) only provides the necessary info when type
is set to optional
. 🤷♂️
#9
@
6 weeks ago
I did!! Thanks for pointing me to it. I'll fix it in https://github.com/buddypress/bp-attachments/issues/116. Let's just use bp_core_get_components()
in BuddyPress 😅.
#10
@
5 weeks ago
@imath,
Added new patch based on the fixed represented by https://github.com/buddypress/bp-attachments/pull/118 and tested to confirm the PR works with the with 9237.02.patch (newly submitted patch).
$all_components = bp_core_get_components(); $active_components = array_merge( buddypress()->active_components, array( 'core' => '1' ) ); $active_components = wp_list_pluck( array_intersect_key( $all_components, $active_components ), 'title' );
site-health-info-bp-panel-15.0.png