#6244 closed defect (bug) (fixed)
Custom Component Directory pages mappings removed when BuddyPress Componets selection saved in admin
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.2.2 | Priority: | high |
Severity: | normal | Version: | 2.2 |
Component: | Administration | Keywords: | has-patch |
Cc: | sbrajesh |
Description
Hi,
In BuddyPress 2.2/2.2.1 when you set the directory pages for a custom component, It works fine but when you try to save the Components from BuddyPress->Components(even if you do not make any change in selection), the mappings for the custom component directory pages are lost and you will get a message 'The following active BuddyPress Components do not have associated WordPress Pages: component name'.
The problem is caused by a change in BuddyPress 2.2. There was a change in the bp_core_get_directory_page_ids that checks for the active components before returning the directory pages.
In the bp_core_admin_components_settings_handler, the active component is being reset by the following code
$bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted );
and then bp_core_add_page_mappings() is called for saving the pages. Since bp_core_add_page_mappings uses bp_core_get_directory_page_ids which in turn checks for the active components, All the custom component associations are lost.
I am not sure if I made myself clear, so here is the step to reproduce it:-
- Install custom component( try buddypress-skeleton-component)
- activate the plugin
- Visit Settings->BuddyPress->Pages and save the associated page for Example component
- Now visit, Settings->BuddyPress->Components and click Save settings. The page association for the Example component will be lost.
A solution can be returning all the core components(selected) as well as all other active components from the 'bp_core_admin_get_active_components_from_submitted_settings' if the checks for bp_is_active('component' ) is to be honored.
Relevant ticket: #6197
Attachments (3)
Change History (20)
#2
@
10 years ago
hi imath,
Yes, I am adding the component to the active components list as in the example component. I also saw the thread on bp.org, That thread is about saving the pages(if component does not add itself to the list of active components, the pages associate is not saved in Settings->BuddyPress->pages).
The above problem is related to resetting the page association when you try to save the components list in the Settings->BuddyPress->Components
You can reproduce the error by using https://github.com/boonebgorges/buddypress-skeleton-component
I have tested it on WP 4.1(non multisite) and BP 2.2.1
#3
@
10 years ago
I see, if i understand well, it works the first time when setting the page association, but if once the association made i click again, setting is lost, is that correct ?
I'll run some tests asap, thanks for your feedback.
#4
@
10 years ago
- Keywords needs-patch needs-unit-tests added; reporter-feedback removed
- Milestone changed from Awaiting Review to 2.2.2
Ok i've managed to reproduce. It's a regression from 2.1. I think we should fix this for 2.2.2.
Working on it.
#5
@
10 years ago
That's awesome. it is being caused due to the bp_is_active check in getting the page ids. Instead of removing that, some change in 'bp_core_admin_get_active_components_from_submitted_settings' can fix the issue.
Looking forward to your patch :)
#6
@
10 years ago
- Keywords has-patch added; needs-patch needs-unit-tests removed
I've chosen to edit the bp_core_admin_get_active_components_from_submitted_settings()
as the bp_is_active()
check in the bp_core_get_directory_page_ids()
was an improvement introduced in 2.2 and i think bp_core_admin_get_active_components_from_submitted_settings()
should only take care of the BuddyPress built in components.
So 6244.patch is setting an array of custom components by difference between the packaged components and the active components. Then i let the switch part do his job : setting the packaged active components. Finally i return the pakaged components + the custom ones by merging the two arrays.
6244.unittest.patch is only containing the unit test.
#7
@
10 years ago
imath - thanks for looking at this. This seems like a good fix. sbrajesh - it'd be great if you could test.
#8
@
10 years ago
This looks good to me.
LOL @ test_bp_core_admin_get_active_components_from_submitted_settings_should_keep_custom_component_directory_page
#10
@
10 years ago
thanks for your feedback sbrajesh, johnjamesjacoby, & boonebgorges
@johnjamesjacoby i'm pretty proud about the name of this test :) but open to improvements, of course ;)
#14
@
10 years ago
- Priority changed from normal to high
- Resolution set to fixed
- Status changed from new to closed
Fixed in 2.2 branch and trunk. Thanks everyone.
Hi sbrajesh
Are you making your component active from your component class like this : https://github.com/boonebgorges/buddypress-skeleton-component/blob/1.7/includes/bp-example-loader.php#L64 ?
There was a problem with BuddyPress links in this area, see my reply on this forum topic https://buddypress.org/support/topic/buddypress-2-2-and-links-page/#post-233733