[buddypress-trac] [BuddyPress Trac] #8507: Implement __isset magic method in BP_Theme_Compat class

buddypress-trac noreply at wordpress.org
Fri Jul 9 04:59:55 UTC 2021

#8507: Implement __isset magic method in BP_Theme_Compat class
 Reporter:  sbrajesh     |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Core         |    Version:
 Severity:  normal       |   Keywords:  has-patch
 The BP Theme_Compat(extended by the Nouveau/legacy) allows adding
 arbitrary dynamic property. It is implemented via magic methods.

 While the class implements the setter and getter, it does not implement
 the __isset magic method.

 That makes any code like following malfunction.

         bp_nouveau()->test_var ="Hello";

         if( ! empty( bp_nouveau()->test_var ) ){
                 echo "Works";
         } else {
                 echo "Does not work";

 It will print "Does not work".

 This leads to a bug in the BP_Nouveau template function


 If you are calling it for a custom component(we implemented a custom
 component for one of our plugins), the expectation is that the following
 code will run

         } elseif ( ! empty( $bp_nouveau->object_nav ) ) {
                 $bp_nouveau->displayed_nav = $bp_nouveau->object_nav;

                  * Use the filter to use your specific Navigation.
                  * Use the $n param to check for your custom object.
                  * @since 3.0.0
                  * @param array $nav The list of item navigations
 generated by the BP_Core_Nav API.
                  * @param array $n   The arguments of the Navigation loop.
                 $nav = apply_filters( 'bp_nouveau_get_nav', $nav, $n );

 (line 844-858 in bp-nouveau/includes/template-tags.php)
 But it will never run.
 The code

 ! empty( $bp_nouveau->object_nav )

 will always return false even when the object_nav property is set.

 I am attaching a patch. Will it be feasible to have it fixed in the next

 Thank you

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

More information about the buddypress-trac mailing list