Skip to:

Opened 9 years ago

Last modified 8 years ago

#6559 new defect (bug)

nav implode() error when using BUDDYPRESS_LATE_LOAD

Reported by: usestrict's profile useStrict Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version:
Component: Core Keywords:


While debugging a conflict between Membermouse and Buddypress (Buddypress wrongly allows a logged-out visitor to see the Members page), I found that letting Membermouse load first with BUDDYPRESS_LATE_LOAD set to true would fix the problem. However, a side-effect is that I then get the following warning for several menu items:

Warning: implode(): Invalid arguments passed in /home/makest/public_html/staging/wp-content/plugins/buddypress/bp-core/bp-core-filters.php on line 853

The menu items in question have _invalid set to true, and therefore have an empty class property (instead of the expected array). I could not figure out why this does not happen without the late load.

The change below seems to resolve the problem:

46 function bp_setup_nav_menu_item( $menu_item ) {
847         if ( is_admin() ) {
848                 return $menu_item;
849         }
851         // We use information stored in the CSS class to determine what kind of
852         // menu item this is, and how it should be treated
854         if ( true === $menu_item->_invalid ) return $menu_item; // THIS CHANGE RESOLVED THE PROBLEM
856         preg_match( '/\sbp-(.*)-nav/', implode( ' ', $menu_item->classes), $matches );

Please advise if there is a better fix, or consider applying this to the core.


Change History (3)

#1 @DJPaul
9 years ago

  • Milestone changed from Awaiting Review to 2.4

Hi useStrict

Nice catch! Welcome to the BuddyPress bug tracker, and thanks for making your first bug report to the projec.t

I think _is_valid_nav_menu_item is what we'd want to use to check the property, but we obviously should figure out what's causing it to not be an array so we can check if that is a separate BP bug or not.

It looks like Membermouse is a paid-for plugin which makes obtaining a copy for testing tricky. Are you interested in helping us debug this?

Version 0, edited 9 years ago by DJPaul (next)

#2 @useStrict
9 years ago

Hi DJPaul,

Unfortunately, I don't have a copy of Membermouse either - I had to try it directly on a client's staging site. To make matters worse, I suspect a large chunk of the their code is garbled by base64 as I failed to find several apply_filters() calls via ack-grep or grep.

I was giving this more thought overnight and figured that perhaps casting $menu_item->classes as an array could do the trick better than my previous solution.

preg_match( '/\sbp-(.*)-nav/', implode( ' ', (array) $menu_item->classes), $matches );

Anyway, I'll try contacting the Membermouse team to try and get a copy to figure out why MM fails to restrict views if BuddyPress is loaded first.


Last edited 9 years ago by useStrict (previous) (diff)

#3 @DJPaul
8 years ago

  • Milestone changed from 2.4 to Future Release
Note: See TracTickets for help on using tickets.