Skip to content

Commit

Permalink
Fix PHP 8.1 fatal error with --orderby=size and --size_format=mb (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber authored Oct 13, 2022
1 parent 2471448 commit 0d9e365
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions features/db-size.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
2 changes: 1 addition & 1 deletion src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 0d9e365

Please sign in to comment.