[wp-trac] [WordPress Trac] #60190: Drop PHP 4 support for arrays with 1 object element
WordPress Trac
noreply at wordpress.org
Thu Jan 4 06:44:57 UTC 2024
#60190: Drop PHP 4 support for arrays with 1 object element
--------------------------------------+------------------------------
Reporter: kkmuffme | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Description changed by sabernhardt:
Old description:
> ```php
> do_action( 'foo', array( (object) null ) );
>
> function foo_cb( array $arg ) {}
> add_action( 'foo', 'foo_cb' );
> ```
>
> This will fail with a fatal error in PHP 7+, since `do_action` (as the
> only one, this isn't an issue with `apply_filters` or
> `do_action_ref_array`) will convert arrays with only 1 object into that
> object.
> The reason for that is some PHP 4 legacy behavior, see
> https://core.trac.wordpress.org/ticket/48312
>
> It's time to drop this PHP 4 support, as this prevent using native types
> in callback functions in cases where the argument is an array of objects.
New description:
{{{#!php
do_action( 'foo', array( (object) null ) );
function foo_cb( array $arg ) {}
add_action( 'foo', 'foo_cb' );
}}}
This will fail with a fatal error in PHP 7+, since `do_action` (as the
only one, this isn't an issue with `apply_filters` or
`do_action_ref_array`) will convert arrays with only 1 object into that
object.
The reason for that is some PHP 4 legacy behavior, see #48312
It's time to drop this PHP 4 support, as this prevent using native types
in callback functions in cases where the argument is an array of objects.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60190#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list