mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-10 21:00:59 +01:00
WP_Debug_Data: Extract wp-database
data into separate method.
This is the part three in a larger modularization of the data in `WP_Debug_Data`. Previously this was a single massive method drawing in debug data from various groups of related data, where the groups were independent from each other. This patch separates the third of twelve groups, the `wp-database` info, into a separate method focused on that data. This work precedes changes to make the `WP_Debug_Data` class more extensible for better use by plugin and theme code. Developed in https://github.com/wordpress/wordpress-develop/7143 Discussed in https://core.trac.wordpress.org/ticket/61648 Props dmsnell, kebbet, apermo. See #61648. Built from https://develop.svn.wordpress.org/trunk@58964 git-svn-id: http://core.svn.wordpress.org/trunk@58360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4fc2975cb5
commit
d0877b108a
@ -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.
|
||||
*
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user