diff --git a/wp-admin/includes/class-wp-debug-data.php b/wp-admin/includes/class-wp-debug-data.php index f626dc4c4a..4b1982454c 100644 --- a/wp-admin/includes/class-wp-debug-data.php +++ b/wp-admin/includes/class-wp-debug-data.php @@ -27,15 +27,15 @@ class WP_Debug_Data { * @since 5.3.0 Added database charset, database collation, * and timezone information. * @since 5.5.0 Added pretty permalinks support information. + * @since 6.7.0 Modularized into separate theme-oriented methods. * * @throws ImagickException - * @global wpdb $wpdb WordPress database abstraction object. * @global array $_wp_theme_features * * @return array The debug data for the site. */ public static function debug_data() { - global $wpdb, $_wp_theme_features; + global $_wp_theme_features; // Save few function calls. $upload_dir = wp_upload_dir(); @@ -694,80 +694,6 @@ class WP_Debug_Data { 'value' => wp_date( 'c', $_SERVER['REQUEST_TIME'] ), ); - // Populate the database debug fields. - if ( is_object( $wpdb->dbh ) ) { - // mysqli or PDO. - $extension = get_class( $wpdb->dbh ); - } else { - // Unknown sql extension. - $extension = null; - } - - $server = $wpdb->get_var( 'SELECT VERSION()' ); - - $client_version = $wpdb->dbh->client_info; - - $info['wp-database']['fields']['extension'] = array( - 'label' => __( 'Extension' ), - 'value' => $extension, - ); - - $info['wp-database']['fields']['server_version'] = array( - 'label' => __( 'Server version' ), - 'value' => $server, - ); - - $info['wp-database']['fields']['client_version'] = array( - 'label' => __( 'Client version' ), - 'value' => $client_version, - ); - - $info['wp-database']['fields']['database_user'] = array( - 'label' => __( 'Database username' ), - 'value' => $wpdb->dbuser, - 'private' => true, - ); - - $info['wp-database']['fields']['database_host'] = array( - 'label' => __( 'Database host' ), - 'value' => $wpdb->dbhost, - 'private' => true, - ); - - $info['wp-database']['fields']['database_name'] = array( - 'label' => __( 'Database name' ), - 'value' => $wpdb->dbname, - 'private' => true, - ); - - $info['wp-database']['fields']['database_prefix'] = array( - 'label' => __( 'Table prefix' ), - 'value' => $wpdb->prefix, - 'private' => true, - ); - - $info['wp-database']['fields']['database_charset'] = array( - 'label' => __( 'Database charset' ), - 'value' => $wpdb->charset, - 'private' => true, - ); - - $info['wp-database']['fields']['database_collate'] = array( - 'label' => __( 'Database collation' ), - 'value' => $wpdb->collate, - 'private' => true, - ); - - $info['wp-database']['fields']['max_allowed_packet'] = array( - 'label' => __( 'Max allowed packet size' ), - 'value' => self::get_mysql_var( 'max_allowed_packet' ), - ); - - $info['wp-database']['fields']['max_connections'] = array( - 'label' => __( 'Max connections number' ), - 'value' => self::get_mysql_var( 'max_connections' ), - ); - // List must use plugins if there are any. $mu_plugins = get_mu_plugins(); @@ -1229,6 +1155,7 @@ class WP_Debug_Data { } $info['wp-constants'] = self::get_wp_constants(); + $info['wp-database'] = self::get_wp_database(); $info['wp-filesystem'] = self::get_wp_filesystem(); /** @@ -1447,6 +1374,90 @@ class WP_Debug_Data { ); } + /** + * Gets the WordPress database section of the debug data. + * + * @since 6.7.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return array + */ + public static function get_wp_database(): array { + global $wpdb; + + // Populate the database debug fields. + if ( is_object( $wpdb->dbh ) ) { + // mysqli or PDO. + $extension = get_class( $wpdb->dbh ); + } else { + // Unknown sql extension. + $extension = null; + } + + $server = $wpdb->get_var( 'SELECT VERSION()' ); + + $client_version = $wpdb->dbh->client_info; + + $fields = array( + 'extension' => array( + 'label' => __( 'Database Extension' ), + 'value' => $extension, + ), + 'server_version' => array( + 'label' => __( 'Server version' ), + 'value' => $server, + ), + 'client_version' => array( + 'label' => __( 'Client version' ), + 'value' => $client_version, + ), + 'database_user' => array( + 'label' => __( 'Database username' ), + 'value' => $wpdb->dbuser, + 'private' => true, + ), + 'database_host' => array( + 'label' => __( 'Database host' ), + 'value' => $wpdb->dbhost, + 'private' => true, + ), + 'database_name' => array( + 'label' => __( 'Database name' ), + 'value' => $wpdb->dbname, + 'private' => true, + ), + 'database_prefix' => array( + 'label' => __( 'Table prefix' ), + 'value' => $wpdb->prefix, + 'private' => true, + ), + 'database_charset' => array( + 'label' => __( 'Database charset' ), + 'value' => $wpdb->charset, + 'private' => true, + ), + 'database_collate' => array( + 'label' => __( 'Database collation' ), + 'value' => $wpdb->collate, + 'private' => true, + ), + 'max_allowed_packet' => array( + 'label' => __( 'Max allowed packet size' ), + 'value' => self::get_mysql_var( 'max_allowed_packet' ), + ), + 'max_connections' => array( + 'label' => __( 'Max connections number' ), + 'value' => self::get_mysql_var( 'max_connections' ), + ), + ); + + return array( + 'label' => __( 'Database' ), + 'fields' => $fields, + ); + } + /** * Gets the file system section of the debug data. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 6453748ba7..b29b1b3cda 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-58963'; +$wp_version = '6.7-alpha-58964'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.