Add “site size” areas to system status report
The size of the site very much impacts the status of the site. This type of information would be extremely helpful when supporting a site. 1) post counts - can reveal high volumes of specific kinds of post types both within WC (orders, products, etc) or outside (revisions, attachments, third party ones, etc) 2) table sizes - a site with a 5MB postmeta table is very different than a site with a 5GB postmeta table, which is different than a site with a 50GB postmeta table, and require different kinds of support and focus.
This commit is contained in:
parent
48a1223dbb
commit
1314158a14
|
@ -16,6 +16,8 @@ if ( ! class_exists( 'WC_REST_System_Status_Controller', false ) ) {
|
||||||
$system_status = new WC_REST_System_Status_Controller;
|
$system_status = new WC_REST_System_Status_Controller;
|
||||||
$environment = $system_status->get_environment_info();
|
$environment = $system_status->get_environment_info();
|
||||||
$database = $system_status->get_database_info();
|
$database = $system_status->get_database_info();
|
||||||
|
$database_size = $system_status->get_database_table_sizes();
|
||||||
|
$post_type_counts = $system_status->get_post_type_counts();
|
||||||
$active_plugins = $system_status->get_active_plugins();
|
$active_plugins = $system_status->get_active_plugins();
|
||||||
$theme = $system_status->get_theme_info();
|
$theme = $system_status->get_theme_info();
|
||||||
$security = $system_status->get_security_info();
|
$security = $system_status->get_security_info();
|
||||||
|
@ -354,6 +356,49 @@ $pages = $system_status->get_pages();
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<table class="wc_status_table widefat" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="3" data-export-label="Database Table Sizes"><h2><?php _e( 'Database Table Sizes', 'woocommerce' ); ?></h2></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ( $database_size as $table ) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo esc_html( $table->name ); ?></td>
|
||||||
|
<td class="help"> </td>
|
||||||
|
<td>
|
||||||
|
<?php _e( 'Data: ', 'woocommerce' ); ?><?php echo wc_format_decimal( $table->data, 2 ); ?>MB,
|
||||||
|
<?php _e( 'Index: ', 'woocommerce' ); ?><?php echo wc_format_decimal( $table->index, 2 ); ?>MB
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="wc_status_table widefat" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="3" data-export-label="Post Type Counts"><h2><?php _e( 'Post Type Counts', 'woocommerce' ); ?></h2></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ( $post_type_counts as $post_type ) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo esc_html( $post_type->type ); ?></td>
|
||||||
|
<td class="help"> </td>
|
||||||
|
<td><?php echo absint( $post_type->count ); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<table class="wc_status_table widefat" cellspacing="0">
|
<table class="wc_status_table widefat" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -670,6 +670,35 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_database_table_sizes() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$database_table_sizes = $wpdb->get_results( $wpdb->prepare( "
|
||||||
|
SELECT
|
||||||
|
table_name AS 'name',
|
||||||
|
round( ( data_length / 1024 / 1024 ), 2 ) 'data',
|
||||||
|
round( ( index_length / 1024 / 1024 ), 2 ) 'index'
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE table_schema = %s
|
||||||
|
ORDER BY name ASC;
|
||||||
|
", DB_NAME ) );
|
||||||
|
|
||||||
|
return is_array( $database_table_sizes ) ? $database_table_sizes : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get array of counts of objects. Orders, products, etc.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_post_type_counts() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$post_type_counts = $wpdb->get_results( "SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;" );
|
||||||
|
|
||||||
|
return is_array( $post_type_counts ) ? $post_type_counts : array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of plugins active on the site.
|
* Get a list of plugins active on the site.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue