[wp-trac] [WordPress Trac] #42898: Make sure get_cli_args() operates on an array
WordPress Trac
noreply at wordpress.org
Wed Dec 13 22:41:47 UTC 2017
#42898: Make sure get_cli_args() operates on an array
--------------------------+-----------------------------
Reporter: josephscott | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Import | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The `get_cli_args()` function in `wp-admin/includes/class-wp-importer.php`
asks for an array from `$_SERVER['argv']`. However, it is possible for
`$_SERVER['argv']` to be NULL. In that case `sizeof()` gets called on a
non-countable variable, resulting in a warning like this under PHP 7.2:
Warning: sizeof(): Parameter must be an array or an object that
implements Countable in /home/wpcom/public_html/wp-admin/includes/class-
wp-importer.php on line 283
By making sure that `$args` is always an array we can fix that:
{{{
if ( !is_array( $args ) ) {
$args = array();
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42898>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list