[Bb-trac] [bbPress] #913: get_forums hierarchical processing breaks if filters are used

bbPress bb-trac at lists.bbpress.org
Sat Aug 2 07:40:18 GMT 2008


#913: get_forums hierarchical processing breaks if filters are used
--------------------------+-------------------------------------------------
 Reporter:  chrispoirier  |       Owner:       
     Type:  defect        |      Status:  new  
 Priority:  normal        |   Milestone:       
Component:  Back-end      |     Version:  0.9.1
 Severity:  normal        |    Keywords:       
--------------------------+-------------------------------------------------
 The code in bb-includes/functions.php/get_forums() that removes forums
 from the calculated forums list, based on $child_of, $hierarchical, or
 $depth processing, uses array index as a substitute for forum ID, which is
 not reliable if apply_filters() processing on the original list actually
 changes the list.  Instead, I suspect the code should build a new array
 and copy elements based on forum ID directly.

 I used the following (simple, stupid, inefficient) hack to resolve a
 problem with the display of forums filtered by the Private Forums plugin:

 {{{
         if ( $child_of || $hierarchical || $depth ) {
                 $_forums = bb_get_forums_hierarchical( $child_of, $depth,
 $forums, true );

                 if ( !is_array( $_forums ) )
                         return false;

                 $_forums = (array) bb_flatten_array( $_forums, $cut_branch
 );

                 $final = array();
                 foreach ( array_keys($_forums) as $_id )
                    foreach( $forums as $forum )
                        if( $forum->forum_id == $_id )
                            $final[] = $forum;

                 $forums = $final;
         }

 }}}

-- 
Ticket URL: <http://trac.bbpress.org/ticket/913>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list