Merge pull request #23101 from woocommerce/update/23090

Add table ENGINE to system status report
This commit is contained in:
Mike Jolley 2019-04-10 11:32:51 +01:00 committed by GitHub
commit 945ff7958f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -475,8 +475,8 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'min
if ( ! $table_data ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Table does not exist', 'woocommerce' ) . '</mark>';
} else {
/* Translators: %1$f: Table size, %2$f: Index size. */
printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), esc_html( wc_format_decimal( $table_data['data'], 2 ) ), esc_html( wc_format_decimal( $table_data['index'], 2 ) ) );
/* Translators: %1$f: Table size, %2$f: Index size, %3$s Engine. */
printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB + Engine %3$s', 'woocommerce' ), esc_html( wc_format_decimal( $table_data['data'], 2 ) ), esc_html( wc_format_decimal( $table_data['index'], 2 ) ), esc_html( $table_data['engine'] ) );
}
?>
</td>
@ -489,8 +489,8 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'min
<td class="help">&nbsp;</td>
<td>
<?php
/* Translators: %1$f: Table size, %2$f: Index size. */
printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), esc_html( wc_format_decimal( $table_data['data'], 2 ) ), esc_html( wc_format_decimal( $table_data['index'], 2 ) ) );
/* Translators: %1$f: Table size, %2$f: Index size, %3$s Engine. */
printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB + Engine %3$s', 'woocommerce' ), esc_html( wc_format_decimal( $table_data['data'], 2 ) ), esc_html( wc_format_decimal( $table_data['index'], 2 ) ), esc_html( $table_data['engine'] ) );
?>
</td>
</tr>

View File

@ -696,10 +696,11 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
public function get_database_info() {
global $wpdb;
$database_table_sizes = $wpdb->get_results(
$database_table_information = $wpdb->get_results(
$wpdb->prepare(
"SELECT
table_name AS 'name',
engine,
round( ( data_length / 1024 / 1024 ), 2 ) 'data',
round( ( index_length / 1024 / 1024 ), 2 ) 'index'
FROM information_schema.TABLES
@ -754,7 +755,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
$site_tables_prefix = $wpdb->get_blog_prefix( get_current_blog_id() );
$global_tables = $wpdb->tables( 'global', true );
foreach ( $database_table_sizes as $table ) {
foreach ( $database_table_information as $table ) {
// Only include tables matching the prefix of the current site, this is to prevent displaying all tables on a MS install not relating to the current.
if ( is_multisite() && 0 !== strpos( $table->name, $site_tables_prefix ) && ! in_array( $table->name, $global_tables, true ) ) {
continue;
@ -764,6 +765,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
$tables[ $table_type ][ $table->name ] = array(
'data' => $table->data,
'index' => $table->index,
'engine' => $table->engine,
);
$database_size['data'] += $table->data;