Closed
Description
Bug Report
Describe the current, buggy behavior
If a get a table with empty extra row values, I see deprecation warnings in PHP 8.2.
wp post list
+-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+---------------------+-------------+
| 729 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor | lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-elitr-sed-diam-nonumy-eirmod-tempor | 2023-07-14 09:49:45 | publish |
+-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+---------------------+-------------+
wp post list
Deprecated: grapheme_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /parship/lamp/htdocs/vendor/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 329
Deprecated: preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated in /parship/lamp/htdocs/vendor/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 331
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /parship/lamp/htdocs/vendor/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php on line 215
Deprecated: str_pad(): Passing null to parameter #1 ($string) of type string is deprecated in /parship/lamp/htdocs/vendor/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php on line 218
...
+-----+-------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+-------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+---------------------+-------------+
| 729 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tem | lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-elitr-sed-diam-nonumy-eirmod-tempor | 2023-07-14 09:49:45 | publish |
| | por | | | |
+-----+-------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+---------------------+-------------+
Let us know what environment you are running this on
PHP version: 8.2.7
WP-CLI version: 2.9.0-alpha
Provide a possible solution
php-cli-tools/lib/cli/table/Ascii.php
Line 183 in 22270f4
We should check if the array is empty:
$row_values[ $col ] = ! empty( $col_values ) ? array_shift( $col_values ) : '';