Skip to:
Content

BuddyPress.org

Changeset 7333


Ignore:
Timestamp:
08/01/2013 12:06:38 AM (11 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:
branches/1.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.8/bp-groups/bp-groups-classes.php

    r7323 r7333  
    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        }
  • branches/1.8/tests/testcases/groups/class-bp-group-extension.php

    r6997 r7333  
    6262
    6363        $fallback = array(
    64             'screen_callback' => array( $class_name, 'settings_screen' ),
    65             'screen_save_callback' => array( $class_name, 'settings_screen_save' ),
     64            'screen_callback' => array( $e, 'settings_screen' ),
     65            'screen_save_callback' => array( $e, 'settings_screen_save' ),
    6666        );
    6767        $fallbacks = array(
     
    9191
    9292        $fallback = array(
    93             'screen_callback' => array( $class_name, 'settings_screen' ),
    94             'screen_save_callback' => array( $class_name, 'settings_screen_save' ),
     93            'screen_callback' => array( $e, 'settings_screen' ),
     94            'screen_save_callback' => array( $e, 'settings_screen_save' ),
    9595        );
    9696        $expected = array(
    9797            'create' => $fallback,
    9898            'edit' => array(
    99                 'screen_callback' => array( $class_name, 'edit_screen' ),
    100                 'screen_save_callback' => array( $class_name, 'edit_screen_save' ),
     99                'screen_callback' => array( $e, 'edit_screen' ),
     100                'screen_save_callback' => array( $e, 'edit_screen_save' ),
    101101            ),
    102102            'admin' => $fallback,
     
    203203        $e->_register();
    204204
    205         $this->assertEquals( array( $class_name, 'settings_screen' ), $e->screens['create']['screen_callback'] );
    206         $this->assertEquals( array( $class_name, 'settings_screen_save' ), $e->screens['create']['screen_save_callback'] );
    207         $this->assertEquals( array( $class_name, 'settings_screen' ), $e->screens['admin']['screen_callback'] );
    208         $this->assertEquals( array( $class_name, 'settings_screen_save' ), $e->screens['admin']['screen_save_callback'] );
    209         $this->assertEquals( array( $class_name, 'edit_screen' ), $e->screens['edit']['screen_callback'] );
    210         $this->assertEquals( array( $class_name, 'edit_screen_save' ), $e->screens['edit']['screen_save_callback'] );
     205        $this->assertEquals( array( $e, 'settings_screen' ), $e->screens['create']['screen_callback'] );
     206        $this->assertEquals( array( $e, 'settings_screen_save' ), $e->screens['create']['screen_save_callback'] );
     207        $this->assertEquals( array( $e, 'settings_screen' ), $e->screens['admin']['screen_callback'] );
     208        $this->assertEquals( array( $e, 'settings_screen_save' ), $e->screens['admin']['screen_save_callback'] );
     209        $this->assertEquals( array( $e, 'edit_screen' ), $e->screens['edit']['screen_callback'] );
     210        $this->assertEquals( array( $e, 'edit_screen_save' ), $e->screens['edit']['screen_save_callback'] );
    211211    }
    212212
Note: See TracChangeset for help on using the changeset viewer.