Skip to content

Commit 0d9e365

Browse files
Fix PHP 8.1 fatal error with --orderby=size and --size_format=mb (#230)
1 parent 2471448 commit 0d9e365

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

features/db-size.feature

+9
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,12 @@ Feature: Display database size
237237
"""
238238
[{"Name":"wp_posts",
239239
"""
240+
241+
Scenario: Display ordered table sizes for a WordPress install
242+
Given a WP install
243+
244+
When I run `wp db size --tables --all-tables --orderby=size --order=desc --size_format=mb`
245+
Then STDOUT should contain:
246+
"""
247+
wp_posts
248+
"""

src/DB_Command.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ public function size( $args, $assoc_args ) {
11021102
$size_format_display = preg_replace( '/IB$/u', 'iB', strtoupper( $size_format ) );
11031103

11041104
$decimals = Utils\get_flag_value( $assoc_args, 'decimals', 0 );
1105-
$rows[ $index ]['Size'] = round( $row['Size'] / $divisor, $decimals ) . ' ' . $size_format_display;
1105+
$rows[ $index ]['Size'] = round( (int) $row['Bytes'] / $divisor, $decimals ) . ' ' . $size_format_display;
11061106
}
11071107
}
11081108

0 commit comments

Comments
 (0)