@@ -27,15 +27,15 @@ public static function check_for_updates() {
2727 * @since 5.3.0 Added database charset, database collation,
2828 * and timezone information.
2929 * @since 5.5.0 Added pretty permalinks support information.
30+ * @since 6.7.0 Modularized into separate theme-oriented methods.
3031 *
3132 * @throws ImagickException
32- * @global wpdb $wpdb WordPress database abstraction object.
3333 * @global array $_wp_theme_features
3434 *
3535 * @return array The debug data for the site.
3636 */
3737 public static function debug_data () {
38- global $ wpdb , $ _wp_theme_features ;
38+ global $ _wp_theme_features ;
3939
4040 // Save few function calls.
4141 $ upload_dir = wp_upload_dir ();
@@ -694,80 +694,6 @@ public static function debug_data() {
694694 'value ' => wp_date ( 'c ' , $ _SERVER ['REQUEST_TIME ' ] ),
695695 );
696696
697- // Populate the database debug fields.
698- if ( is_object ( $ wpdb ->dbh ) ) {
699- // mysqli or PDO.
700- $ extension = get_class ( $ wpdb ->dbh );
701- } else {
702- // Unknown sql extension.
703- $ extension = null ;
704- }
705-
706- $ server = $ wpdb ->get_var ( 'SELECT VERSION() ' );
707-
708- $ client_version = $ wpdb ->dbh ->client_info ;
709-
710- $ info ['wp-database ' ]['fields ' ]['extension ' ] = array (
711- 'label ' => __ ( 'Extension ' ),
712- 'value ' => $ extension ,
713- );
714-
715- $ info ['wp-database ' ]['fields ' ]['server_version ' ] = array (
716- 'label ' => __ ( 'Server version ' ),
717- 'value ' => $ server ,
718- );
719-
720- $ info ['wp-database ' ]['fields ' ]['client_version ' ] = array (
721- 'label ' => __ ( 'Client version ' ),
722- 'value ' => $ client_version ,
723- );
724-
725- $ info ['wp-database ' ]['fields ' ]['database_user ' ] = array (
726- 'label ' => __ ( 'Database username ' ),
727- 'value ' => $ wpdb ->dbuser ,
728- 'private ' => true ,
729- );
730-
731- $ info ['wp-database ' ]['fields ' ]['database_host ' ] = array (
732- 'label ' => __ ( 'Database host ' ),
733- 'value ' => $ wpdb ->dbhost ,
734- 'private ' => true ,
735- );
736-
737- $ info ['wp-database ' ]['fields ' ]['database_name ' ] = array (
738- 'label ' => __ ( 'Database name ' ),
739- 'value ' => $ wpdb ->dbname ,
740- 'private ' => true ,
741- );
742-
743- $ info ['wp-database ' ]['fields ' ]['database_prefix ' ] = array (
744- 'label ' => __ ( 'Table prefix ' ),
745- 'value ' => $ wpdb ->prefix ,
746- 'private ' => true ,
747- );
748-
749- $ info ['wp-database ' ]['fields ' ]['database_charset ' ] = array (
750- 'label ' => __ ( 'Database charset ' ),
751- 'value ' => $ wpdb ->charset ,
752- 'private ' => true ,
753- );
754-
755- $ info ['wp-database ' ]['fields ' ]['database_collate ' ] = array (
756- 'label ' => __ ( 'Database collation ' ),
757- 'value ' => $ wpdb ->collate ,
758- 'private ' => true ,
759- );
760-
761- $ info ['wp-database ' ]['fields ' ]['max_allowed_packet ' ] = array (
762- 'label ' => __ ( 'Max allowed packet size ' ),
763- 'value ' => self ::get_mysql_var ( 'max_allowed_packet ' ),
764- );
765-
766- $ info ['wp-database ' ]['fields ' ]['max_connections ' ] = array (
767- 'label ' => __ ( 'Max connections number ' ),
768- 'value ' => self ::get_mysql_var ( 'max_connections ' ),
769- );
770-
771697 // List must use plugins if there are any.
772698 $ mu_plugins = get_mu_plugins ();
773699
@@ -1229,6 +1155,7 @@ public static function debug_data() {
12291155 }
12301156
12311157 $ info ['wp-constants ' ] = self ::get_wp_constants ();
1158+ $ info ['wp-database ' ] = self ::get_wp_database ();
12321159 $ info ['wp-filesystem ' ] = self ::get_wp_filesystem ();
12331160
12341161 /**
@@ -1447,6 +1374,90 @@ public static function get_wp_constants(): array {
14471374 );
14481375 }
14491376
1377+ /**
1378+ * Gets the WordPress database section of the debug data.
1379+ *
1380+ * @since 6.7.0
1381+ *
1382+ * @global wpdb $wpdb WordPress database abstraction object.
1383+ *
1384+ * @return array
1385+ */
1386+ public static function get_wp_database (): array {
1387+ global $ wpdb ;
1388+
1389+ // Populate the database debug fields.
1390+ if ( is_object ( $ wpdb ->dbh ) ) {
1391+ // mysqli or PDO.
1392+ $ extension = get_class ( $ wpdb ->dbh );
1393+ } else {
1394+ // Unknown sql extension.
1395+ $ extension = null ;
1396+ }
1397+
1398+ $ server = $ wpdb ->get_var ( 'SELECT VERSION() ' );
1399+
1400+ $ client_version = $ wpdb ->dbh ->client_info ;
1401+
1402+ $ fields = array (
1403+ 'extension ' => array (
1404+ 'label ' => __ ( 'Database Extension ' ),
1405+ 'value ' => $ extension ,
1406+ ),
1407+ 'server_version ' => array (
1408+ 'label ' => __ ( 'Server version ' ),
1409+ 'value ' => $ server ,
1410+ ),
1411+ 'client_version ' => array (
1412+ 'label ' => __ ( 'Client version ' ),
1413+ 'value ' => $ client_version ,
1414+ ),
1415+ 'database_user ' => array (
1416+ 'label ' => __ ( 'Database username ' ),
1417+ 'value ' => $ wpdb ->dbuser ,
1418+ 'private ' => true ,
1419+ ),
1420+ 'database_host ' => array (
1421+ 'label ' => __ ( 'Database host ' ),
1422+ 'value ' => $ wpdb ->dbhost ,
1423+ 'private ' => true ,
1424+ ),
1425+ 'database_name ' => array (
1426+ 'label ' => __ ( 'Database name ' ),
1427+ 'value ' => $ wpdb ->dbname ,
1428+ 'private ' => true ,
1429+ ),
1430+ 'database_prefix ' => array (
1431+ 'label ' => __ ( 'Table prefix ' ),
1432+ 'value ' => $ wpdb ->prefix ,
1433+ 'private ' => true ,
1434+ ),
1435+ 'database_charset ' => array (
1436+ 'label ' => __ ( 'Database charset ' ),
1437+ 'value ' => $ wpdb ->charset ,
1438+ 'private ' => true ,
1439+ ),
1440+ 'database_collate ' => array (
1441+ 'label ' => __ ( 'Database collation ' ),
1442+ 'value ' => $ wpdb ->collate ,
1443+ 'private ' => true ,
1444+ ),
1445+ 'max_allowed_packet ' => array (
1446+ 'label ' => __ ( 'Max allowed packet size ' ),
1447+ 'value ' => self ::get_mysql_var ( 'max_allowed_packet ' ),
1448+ ),
1449+ 'max_connections ' => array (
1450+ 'label ' => __ ( 'Max connections number ' ),
1451+ 'value ' => self ::get_mysql_var ( 'max_connections ' ),
1452+ ),
1453+ );
1454+
1455+ return array (
1456+ 'label ' => __ ( 'Database ' ),
1457+ 'fields ' => $ fields ,
1458+ );
1459+ }
1460+
14501461 /**
14511462 * Gets the file system section of the debug data.
14521463 *
0 commit comments