From 2e57e86f96acd64684a600f2324324030aff7f76 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 12 Oct 2022 11:56:17 -0700 Subject: [PATCH 1/2] Add a test case for a potential PHP 8.1 failure --- features/db-size.feature | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/features/db-size.feature b/features/db-size.feature index 1ddacbfd..12e74376 100644 --- a/features/db-size.feature +++ b/features/db-size.feature @@ -237,3 +237,12 @@ Feature: Display database size """ [{"Name":"wp_posts", """ + + Scenario: Display ordered table sizes for a WordPress install + Given a WP install + + When I run `wp db size --tables --all-tables --orderby=size --order=desc --size_format=mb` + Then STDOUT should contain: + """ + wp_posts + """ From 210ebcca1f28275d61c6a248a94da86d566ef9dd Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 12 Oct 2022 12:14:00 -0700 Subject: [PATCH 2/2] `$row['Bytes']` shouldn't ever have a unit after it --- src/DB_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DB_Command.php b/src/DB_Command.php index d1a4f60d..e51fc1dc 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1102,7 +1102,7 @@ public function size( $args, $assoc_args ) { $size_format_display = preg_replace( '/IB$/u', 'iB', strtoupper( $size_format ) ); $decimals = Utils\get_flag_value( $assoc_args, 'decimals', 0 ); - $rows[ $index ]['Size'] = round( $row['Size'] / $divisor, $decimals ) . ' ' . $size_format_display; + $rows[ $index ]['Size'] = round( (int) $row['Bytes'] / $divisor, $decimals ) . ' ' . $size_format_display; } }