[buddypress-trac] [BuddyPress Trac] #6085: Possible Bug - Notice of Undefined index: position in bp-core-template.php

buddypress-trac noreply at wordpress.org
Wed Dec 31 23:19:48 UTC 2014


#6085: Possible Bug - Notice of Undefined index: position in bp-core-template.php
--------------------------+-----------------------------
 Reporter:  espellcaste   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:  2.1
 Severity:  normal        |   Keywords:  2nd-opinion
--------------------------+-----------------------------
 I'm not 100% sure if it is a bug in BuddyPress, but I'm posting here to
 give the core developers an opportunity to confirm it.

 When I tried to unset a few $bp_options_nav, I started to get the current
 notice:

 ''Notice: Undefined index: position in PATH\wp-content\plugins\buddypress
 \bp-core\bp-core-template.php on line 2512''

 Below is a function so that you can test it, it is similar to the one I
 used:


 {{{
 function test_remove_submenu_item() {
         global $bp;

         unset($bp->bp_options_nav['profile']['public']);
 }
 add_action('bp_setup_nav', 'test_remove_submenu_item', 201);
 }}}


 After taking a closer look at the problematic function
 _bp_nav_menu_sort(), I changed and solved the notice with the below
 change:

 {{{
 function _bp_nav_menu_sort( $a, $b ) {
         if ( !isset($a['position']) && !isset($b['position']) );
                 return;

         if ( $a['position'] == $b['position'] ) {
                 return 0;
         } elseif ( $a['position'] < $b['position'] ) {
                 return -1;
         } else {
                 return 1;
         }
 }
 }}}


 '''Interesting Point:'''

 - The noticed only appeared to non logged in users, public users wouldn't
 get the notice.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6085>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list