#7931 closed defect (bug) (fixed)
Possible regression in bp_core_new_subnav_item()
Reported by: | dontdream | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 3.2.0 | Priority: | normal |
Severity: | normal | Version: | 3.0.0 |
Component: | Navigation | Keywords: | has-patch has-unit-tests |
Cc: |
Description
The attached code snippet adds a new tab to a members's Settings menu, and works fine on BP 2.9.4 and earlier versions.
On BP 3.0.0 and 3.1.0 it adds the new tab but, when I click the tab link, I get a 404 page instead of the tab content.
Reverting changeset 11814 in bp-core-buddybar.php makes the code work again.
Thanks for looking into this!
Attachments (3)
Change History (12)
#1
@
6 years ago
- Keywords 2nd-opinion added
Thanks for the report.
You might want to check out the note here:
https://buddypress.trac.wordpress.org/ticket/7659#comment:7
The problem is hooking to 'bp_setup_nav'
. Try hooking to 'bp_settings_setup_nav'
or 'bp_setup_nav'
at a later priority as you want to ensure that the Settings nav is setup before registering your subnav.
#2
@
6 years ago
- Keywords has-patch added; 2nd-opinion removed
- Milestone changed from Awaiting Review to 3.2.0
Actually, you are right, @dontdream !
Instead of returning if no parent nav is found, we can check if there is a parent nav, if so, we can use reset()
.
I tested the example code in #7659 and your test example and both test cases work.
#3
@
6 years ago
I think that 7931.01.patch will work for the issue described in https://buddypress.trac.wordpress.org/ticket/7659#comment:7. Can you think of any problems that might arise from this "loosening"? That is, we'll no longer be rejecting items registered against non-existent parents. I think that these items would just be ignored during normal rendering anyway, but it's worth thinking about.
#4
@
6 years ago
I think we should be safe due to the conditional checking for the slug with bp_is_current_action()
and with the parent nav screen function check:
https://buddypress.trac.wordpress.org/browser/tags/3.1.0/src/bp-core/bp-core-buddybar.php?marks=617,618,625#L588
#6
@
6 years ago
- Keywords has-unit-tests added
I've added a unit test that exhibits the problem.
@boonebgorges - Can you go over the naming of the unit test? I'm not usually good at naming these things.
demonstrates possible regression in bp_core_new_subnav_item()