Opened 9 years ago
Closed 9 years ago
#7020 closed defect (bug) (fixed)
bp_notifications_get_notifications_for_user() bug
Reported by: | rogercoathup | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 1.9 |
Component: | Toolbar & Notifications | Keywords: | dev-feedback has-patch commit |
Cc: |
Description
We pass an array to apply_filters_ref_array in bp_notifications_get_notifications_for_user()
i.e.
<?php $ref_array = array( $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count, $format );
The first parameter should be modifiable content for filtering, not the action name.
With the current setup, if a hook returns content, the action name is overwritten in apply_filters_ref_array() and invalid in any subsequent hooks hooked on bp_notifications_get_notifications_for_user.
Attachments (1)
Change History (8)
#1
@
9 years ago
- Keywords dev-feedback added
- Milestone changed from Awaiting Review to 2.6
- Version changed from 2.5.0 to 1.9
#3
@
9 years ago
- Keywords has-patch added
01.patch
modifies the 'bp_notifications_get_notifications_for_user'
filter to do the following:
- Introduces two new parameters -
$component_action_name
and$component_name
as the 6th and 7th parameters to the filter. - Deprecates the first parameter in the filter. It is recommended to do notification action checks against the 6th parameter from now on.
- Adds proper documentation for the filter.
#4
@
9 years ago
Thanks @r-a-y -- in this case, our component is derived from BP_Component, but I hadn't realised the class supported a notification callback to format notifications
Related: #6669, #bbPress2665.
The
'bp_notifications_get_notifications_for_user'
filter is quite weird indeed. You either have to return a string of the content orarray( 'text' => 'CONTENT', 'link' => 'LINK' )
depending on the$format
. I think this needs better documentation.If a plugin does change the value of
$component_action_name
, then no other plugin can do checks against$component_action_name
. comment:8:ticket:6669 goes into the problem as well.We probably need to add some additional parameters so the action is passed again for better checks:
Unfortunately, this does not fix the issue. We might need to think about deprecating this filter for something else.
For an alternative way to formatting your custom notifications, read the latter half of comment:4:ticket:6669.