Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#42898 closed defect (bug) (fixed)

Make sure get_cli_args() operates on an array

Reported by: josephscott's profile josephscott Owned by: ocean90's profile ocean90
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Import Keywords: has-patch
Focuses: Cc:


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();

Attachments (1)

42898.patch (430 bytes) - added by josephscott 6 years ago.

Download all attachments as: .zip

Change History (4)

6 years ago

#1 @ocean90
6 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 42771:

Import: Avoid counting an uncountable type when reading arguments passed to a script.

Props josephscott.
Fixes #42898.

#2 @ocean90
6 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 5.0
  • Version trunk deleted

#3 @johnbillion
6 years ago

  • Milestone changed from 5.0 to 5.1
Note: See TracTickets for help on using tickets.