Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5126 closed defect (bug) (fixed)

BP_Group_Extension::get_screen_callback() returns values incompatible with PHP 5.2.x

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 1.8.1 Priority: high
Severity: critical Version: 1.8
Component: Groups Keywords:
Cc:

Description

In BP_Group_Extension::get_screen_callback(), the callback is set with the format:

array( $this->class_name, $method )

Because the class name is used as the first item in the array, rather than the object itself, you end up with the method being called statically. This causes a problem when a plugin uses the $this keyword in a callback (such as a create_screen() method using $this->slug to check something).

For some reason, this is only causing discernible problems on PHP 5.2.x, where it's causing fatal errors in these cases. (See, eg, https://github.com/boonebgorges/buddypress-docs/issues/350.) For some reason I haven't figured out yet, PHP 5.3+ references the object in the callback rather than the class.

In any case, this can be easily corrected by setting the callback as follows (non-statically):

array( $this, $method )

Change History (2)

#1 @boonebgorges
11 years ago

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

In 7332:

Define BP_Group_Extension screen callbacks non-statically

These callbacks should not be defined statically, because then the $this
keyword is not available in the callbacks. This causes backward compatibility
issues, especially with PHP 5.2.x, where it results in fatal errors.

Fixes #5126

#2 @boonebgorges
11 years ago

In 7333:

Define BP_Group_Extension screen callbacks non-statically

These callbacks should not be defined statically, because then the $this
keyword is not available in the callbacks. This causes backward compatibility
issues, especially with PHP 5.2.x, where it results in fatal errors.

Fixes #5126

Note: See TracTickets for help on using tickets.