diff --git a/functions.php b/functions.php index 6a074de..7fbec06 100644 --- a/functions.php +++ b/functions.php @@ -184,11 +184,14 @@ function upload_results( $results, $rev, $message, $env, $api_key ) { * Get the environmental details */ function get_env_details() { + $WPT_DB_HOST = getenv( 'WPT_DB_HOST' ) ? : 'localhost'; + $WPT_DB_USER = getenv( 'WPT_DB_USER' ); + $WPT_DB_PASSWORD = getenv( 'WPT_DB_PASSWORD' ); + $WPT_DB_NAME = getenv( 'WPT_DB_NAME' ); $env = array( 'php_version' => phpversion(), 'php_modules' => array(), 'system_utils' => array(), - 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), 'os_version' => trim( shell_exec( 'uname -r' ) ), ); @@ -235,6 +238,10 @@ function get_env_details() { $curl_bits = explode( PHP_EOL, str_replace( 'curl ', '', shell_exec( 'curl --version' ) ) ); $curl = array_shift( $curl_bits ); $env['system_utils']['curl'] = trim( $curl ); + $mysqli = new mysqli($WPT_DB_HOST, $WPT_DB_USER, $WPT_DB_PASSWORD, $WPT_DB_NAME); + $env['mysql_version'] = $mysqli->query("SELECT VERSION()")->fetch_row()[0]; + $mysqli->close(); + if ( class_exists( 'Imagick' ) ) { $imagick = new Imagick(); $version = $imagick->getVersion(); diff --git a/prepare.php b/prepare.php index 53b6f03..f6dbab6 100644 --- a/prepare.php +++ b/prepare.php @@ -160,7 +160,6 @@ 'php_version' => phpversion(), 'php_modules' => array(), 'system_utils' => array(), - 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), 'os_version' => trim( shell_exec( 'uname -r' ) ), ); @@ -219,6 +218,10 @@ \$env['system_utils']['graphicsmagick'] = \$version[1]; } \$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) ); + +\$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); +\$env['mysql_version'] = \$mysqli->query("SELECT VERSION()")->fetch_row()[0]; +\$mysqli->close(); file_put_contents( __DIR__ . '/tests/phpunit/build/logs/env.json', json_encode( \$env, JSON_PRETTY_PRINT ) ); if ( 'cli' === php_sapi_name() && defined( 'WP_INSTALLING' ) && WP_INSTALLING ) { echo PHP_EOL;