Skip to:

Opened 3 years ago

Closed 3 years ago

#8507 closed enhancement (fixed)

Implement __isset magic method in BP_Theme_Compat class

Reported by: sbrajesh's profile sbrajesh Owned by: imath's profile imath
Milestone: 9.0.0 Priority: normal
Severity: normal Version:
Component: Core 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 release?

Thank you

Attachments (1)

8507.diff (700 bytes) - added by sbrajesh 3 years ago.

Download all attachments as: .zip

Change History (3)

3 years ago

#1 @imath
3 years ago

  • Milestone changed from Awaiting Review to 9.0.0

Thanks for your ticket, patch and explanations. I'll try to look at it asap.

#2 @imath
3 years ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13013:

Implement an __isset magic method inside the BP_Theme_Compat class

Props sbrajesh

Fixes #8507

Note: See TracTickets for help on using tickets.