Make WordPress Core


Ignore:
Timestamp:
10/22/2019 12:09:39 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Plugins: Restore backward compatibility for PHP4-style passing of array( &$this ) as action argument to do_action().

This is a follow-up to [46149] to avoid unnecessary breakage in case of using the old notation.

Props david.binda, jrf.
Reviewed by azaozz.
Fixes #48312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/actions.php

    r42343 r46568  
    152152        $argsvar3 = $a3->get_args();
    153153        $this->assertEquals( array( $val1, $val2 ), array_pop( $argsvar3 ) );
     154    }
     155
     156    /**
     157     * Tests PHP 4 notation for calling actions while passing in an object by reference.
     158     *
     159     * @ticket 48312
     160     */
     161    function test_action_args_with_php4_syntax() {
     162        $a   = new MockAction();
     163        $tag = __FUNCTION__;
     164        $val = new stdClass;
     165
     166        add_action( $tag, array( &$a, 'action' ) );
     167        // Ñall the action with PHP 4 notation for passing object by reference.
     168        do_action( $tag, array( &$val ) );
     169
     170        $call_count = $a->get_call_count();
     171        $argsvar    = $a->get_args();
     172        $this->assertSame( array( $val ), array_pop( $argsvar ) );
    154173    }
    155174
Note: See TracChangeset for help on using the changeset viewer.