Opened 12 years ago
Closed 12 years ago
#4533 closed defect (bug) (fixed)
Avoid "Notice: Undefined index" in bp_core_remove_nav_item
Reported by: | wpdennis | Owned by: | |
---|---|---|---|
Milestone: | 1.7 | Priority: | normal |
Severity: | trivial | Version: | |
Component: | Core | Keywords: | has-patch |
Cc: | jkudish |
Description
I added an action to "bp_setup_nav" to remove nav items like:
bp_core_remove_nav_item('blogs'); bp_core_remove_nav_item('forums');
This can result in "Notice: Undefined index" in line 389
http://buddypress.trac.wordpress.org/browser/trunk/bp-core/bp-core-buddybar.php#L389.
Maybe we could avoid this in bp_core_remove_nav_item by adding:
if (!isset($bp->bp_nav[$parent_id])) return;
just before this if statement:
if ( $function = $bp->bp_nav[$parent_id]['screen_function'] ) {
Attachments (1)
Change History (7)
#1
follow-up:
↓ 3
@
12 years ago
- Milestone changed from Awaiting Review to 1.7
- Resolution set to fixed
- Status changed from new to closed
#3
in reply to:
↑ 1
@
12 years ago
Replying to boonebgorges:
Great suggestion. We should actually return false (or maybe an error) so that plugin authors can get an appropriate response.
Thanks for your feedback.
Returning false would be even better than returning void. I would prefer false over an error, because it seems to be more consistent to me (bp_core_new_nav_item, bp_core_sort_nav_items & Co).
Great suggestion. We should actually return false (or maybe an error) so that plugin authors can get an appropriate response.