Skip to:
Content

Changeset 7332


Ignore:
Timestamp:
08/01/2013 12:02:10 AM (5 years ago)
Author:
boonebgorges
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r7322 r7332  
    25812581        $rmethod = $this->class_reflection->getMethod( $method );
    25822582        if ( isset( $rmethod->class ) && $this->class_name === $rmethod->class ) {
    2583             $callback = array( $this->class_name, $method );
     2583            $callback = array( $this, $method );
    25842584        }
    25852585
     
    25882588            $rfallback_method = $this->class_reflection->getMethod( $fallback_method );
    25892589            if ( isset( $rfallback_method->class ) && $this->class_name === $rfallback_method->class ) {
    2590                 $callback = array( $this->class_name, $fallback_method );
     2590                $callback = array( $this, $fallback_method );
    25912591            }
    25922592        }
  • trunk/tests/testcases/groups/class-bp-group-extension.php

    r7293 r7332  
    6363
    6464        $fallback = array(
    65             'screen_callback' => array( $class_name, 'settings_screen' ),
    66             'screen_save_callback' => array( $class_name, 'settings_screen_save' ),
     65            'screen_callback' => array( $e, 'settings_screen' ),
     66            'screen_save_callback' => array( $e, 'settings_screen_save' ),
    6767        );
    6868        $fallbacks = array(
     
    9292
    9393        $fallback = array(
    94             'screen_callback' => array( $class_name, 'settings_screen' ),
    95             'screen_save_callback' => array( $class_name, 'settings_screen_save' ),
     94            'screen_callback' => array( $e, 'settings_screen' ),
     95            'screen_save_callback' => array( $e, 'settings_screen_save' ),
    9696        );
    9797        $expected = array(
    9898            'create' => $fallback,
    9999            'edit' => array(
    100                 'screen_callback' => array( $class_name, 'edit_screen' ),
    101                 'screen_save_callback' => array( $class_name, 'edit_screen_save' ),
     100                'screen_callback' => array( $e, 'edit_screen' ),
     101                'screen_save_callback' => array( $e, 'edit_screen_save' ),
    102102            ),
    103103            'admin' => $fallback,
     
    204204        $e->_register();
    205205
    206         $this->assertEquals( array( $class_name, 'settings_screen' ), $e->screens['create']['screen_callback'] );
    207         $this->assertEquals( array( $class_name, 'settings_screen_save' ), $e->screens['create']['screen_save_callback'] );
    208         $this->assertEquals( array( $class_name, 'settings_screen' ), $e->screens['admin']['screen_callback'] );
    209         $this->assertEquals( array( $class_name, 'settings_screen_save' ), $e->screens['admin']['screen_save_callback'] );
    210         $this->assertEquals( array( $class_name, 'edit_screen' ), $e->screens['edit']['screen_callback'] );
    211         $this->assertEquals( array( $class_name, 'edit_screen_save' ), $e->screens['edit']['screen_save_callback'] );
     206        $this->assertEquals( array( $e, 'settings_screen' ), $e->screens['create']['screen_callback'] );
     207        $this->assertEquals( array( $e, 'settings_screen_save' ), $e->screens['create']['screen_save_callback'] );
     208        $this->assertEquals( array( $e, 'settings_screen' ), $e->screens['admin']['screen_callback'] );
     209        $this->assertEquals( array( $e, 'settings_screen_save' ), $e->screens['admin']['screen_save_callback'] );
     210        $this->assertEquals( array( $e, 'edit_screen' ), $e->screens['edit']['screen_callback'] );
     211        $this->assertEquals( array( $e, 'edit_screen_save' ), $e->screens['edit']['screen_save_callback'] );
    212212    }
    213213
Note: See TracChangeset for help on using the changeset viewer.