| | 928 | $info['wp-database']['fields']['max_allowed_packet'] = array( |
| | 929 | 'label' => __( 'Max allowed packet size' ), |
| | 930 | 'value' => self::get_mysql_var( 'max_allowed_packet' ), |
| | 931 | ); |
| | 932 | |
| | 933 | $info['wp-database']['fields']['max_connections'] = array( |
| | 934 | 'label' => __( 'Max connections number' ), |
| | 935 | 'value' => self::get_mysql_var( 'max_connections' ), |
| | 936 | ); |
| | 937 | |
| | 938 | $info['wp-database']['fields']['query_cache_size'] = array( |
| | 939 | 'label' => __( 'Query cache size' ), |
| | 940 | 'value' => self::get_mysql_var( 'query_cache_size' ), |
| | 941 | ); |
| | 942 | |
| | 1463 | * Returns the value of a MySQL variable. |
| | 1464 | * |
| | 1465 | * @since 5.9.0 |
| | 1466 | * |
| | 1467 | * @param string $var Name of the MySQL variable. |
| | 1468 | * @return string|null The variable value on success. Null if the variable does not exist. |
| | 1469 | */ |
| | 1470 | public static function get_mysql_var( $var ) { |
| | 1471 | global $wpdb; |
| | 1472 | |
| | 1473 | $result = $wpdb->get_row( |
| | 1474 | $wpdb->prepare( 'SHOW VARIABLES LIKE %s', $var ), |
| | 1475 | ARRAY_A |
| | 1476 | ); |
| | 1477 | |
| | 1478 | if ( ! empty( $result ) && array_key_exists( 'Value', $result ) ) { |
| | 1479 | return $result['Value']; |
| | 1480 | } |
| | 1481 | |
| | 1482 | return null; |
| | 1483 | } |
| | 1484 | |
| | 1485 | /** |