Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Automator_System_Report::get_database_info()
Return Return
(array)
Source Source
File: src/core/lib/utilities/class-automator-system-report.php
public function get_database_info() { global $wpdb; $tables = array(); $database_size = array(); // It is not possible to get the database name from some classes that replace wpdb (e.g., HyperDB) // and that is why this if condition is needed. if ( defined( 'DB_NAME' ) ) { $database_table_information = $wpdb->get_results( $wpdb->prepare( "SELECT table_name AS 'name', engine AS 'engine', 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 ) ); // Automator Core tables to check existence of. $core_tables = (object) apply_filters( 'automator_database_tables', (object) array( 'recipe' => 'uap_recipe_log', 'trigger' => 'uap_trigger_log', 'trigger_meta' => 'uap_trigger_log_meta', 'action' => 'uap_action_log', 'action_meta' => 'uap_action_log_meta', 'closure' => 'uap_closure_log', 'closure_meta' => 'uap_closure_log_meta', 'recipe_logs' => 'uap_recipe_logs_view', 'trigger_logs' => 'uap_trigger_logs_view', 'action_logs' => 'uap_action_logs_view', ) ); /** * Adding the prefix to the tables array, for backwards compatibility. * * If we changed the tables above to include the prefix, then any filters against that table could break. */ $core_tables = array_map( array( $this, 'add_db_table_prefix' ), (array) $core_tables ); /** * Organize Automator and non-Automator tables separately for display purposes later. * * To ensure we include all Automator tables, even if they do not exist, pre-populate the Automator array with all the tables. */ $tables = array( 'automator' => array_fill_keys( $core_tables, false ), 'other' => array(), ); $database_size = array( 'data' => 0, 'index' => 0, ); $site_tables_prefix = $wpdb->get_blog_prefix( get_current_blog_id() ); $global_tables = $wpdb->tables( 'global', true ); 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; } $table_type = in_array( $table->name, $core_tables, true ) ? 'automator' : 'other'; $tables[ $table_type ][ $table->name ] = array( 'data' => $table->data, 'index' => $table->index, 'engine' => $table->engine, ); $database_size['data'] += $table->data; $database_size['index'] += $table->index; } } // Return all database info. Described by JSON Schema. return array( 'automator_database_version' => get_option( 'uap_database_version' ), 'automator_database_available_version' => AUTOMATOR_DATABASE_VERSION, 'automator_database_views_version' => get_option( 'uap_database_views_version' ), 'automator_database_available_view_version' => AUTOMATOR_DATABASE_VIEWS_VERSION, 'database_prefix' => $wpdb->prefix, 'database_tables' => $tables, 'database_size' => $database_size, ); }
Expand full source code Collapse full source code View on Github