diff --git a/functions.php b/functions.php
index 3df9343..f7d5981 100644
--- a/functions.php
+++ b/functions.php
@@ -280,19 +280,28 @@ function upload_results( $results, $rev, $message, $env, $api_key ) {
  * @uses class_exists() to check for the availability of the Imagick and Gmagick classes for version detection.
  */
 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' );
+
+	$gd_info = array();
+	if( extension_loaded( 'gd' ) ) {
+		$gd_info = gd_info();
+	}
+	$imagick_info = array();
+	if( extension_loaded( 'imagick' ) ) {
+		$imagick_info = Imagick::queryFormats();
+	}
+
 	$env = array(
 		'php_version'    => phpversion(),
 		'php_modules'    => array(),
-		'gd_info'        => extension_loaded( 'gd' ) ? gd_info() : array(),
-		'imagick_info'   => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : array(),
+		'gd_info'        => $gd_info,
+		'imagick_info'   => $imagick_info,
+		'mysql_version'  => trim( shell_exec( 'mysql --version' ) ),
 		'system_utils'   => array(),
 		'os_name'        => trim( shell_exec( 'uname -s' ) ),
 		'os_version'     => trim( shell_exec( 'uname -r' ) ),
 	);
+	unset( $gd_info, $imagick_info );
+
 	$php_modules = array(
 		'bcmath',
 		'ctype',
@@ -333,12 +342,22 @@ function get_env_details() {
 	foreach( $php_modules as $php_module ) {
 		$env['php_modules'][ $php_module ] = phpversion( $php_module );
 	}
+
 	function curl_selected_bits($k) { return in_array($k, array('version', 'ssl_version', 'libz_version')); }
 	$curl_bits = curl_version();
 	$env['system_utils']['curl'] = implode(' ',array_values(array_filter($curl_bits, 'curl_selected_bits',ARRAY_FILTER_USE_KEY) ));
-	$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();
+
+	$WPT_DB_HOST		 	= trim( getenv( 'WPT_DB_HOST' ) );
+	if( ! $WPT_DB_HOST ) {
+		$WPT_DB_HOST = 'localhost';
+	}
+	$WPT_DB_USER 			= trim( getenv( 'WPT_DB_USER' ) );
+	$WPT_DB_PASSWORD 	= trim( getenv( 'WPT_DB_PASSWORD' ) );
+	$WPT_DB_NAME 			= trim( getenv( 'WPT_DB_NAME' ) );
+
+	//$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();
@@ -351,6 +370,8 @@ function curl_selected_bits($k) { return in_array($k, array('version', 'ssl_vers
 		preg_match( '/Magick (\d+\.\d+\.\d+-\d+|\d+\.\d+\.\d+|\d+\.\d+\-\d+|\d+\.\d+)/', $version['versionString'], $version );
 		$env['system_utils']['graphicsmagick'] = $version[1];
 	}
+
 	$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) );
+
 	return $env;
 }
diff --git a/prepare.php b/prepare.php
index 52b5aa1..2948b70 100644
--- a/prepare.php
+++ b/prepare.php
@@ -155,11 +155,20 @@
 	mkdir( __DIR__ . '/tests/phpunit/build/logs/', 0777, true );
 }
 // Log environment details that are useful to have reported.
+\$gd_info = array();
+if( extension_loaded( 'gd' ) ) {
+	\$gd_info = gd_info();
+}
+\$imagick_info = array();
+if( extension_loaded( 'imagick' ) ) {
+	\$imagick_info = Imagick::queryFormats();
+}
 \$env = array(
 	'php_version'    => phpversion(),
 	'php_modules'    => array(),
-	'gd_info'        => extension_loaded( 'gd' ) ? gd_info() : array(),
-	'imagick_info'   => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : array(),
+	'gd_info'        => \$gd_info,
+	'imagick_info'   => \$imagick_info,
+	'mysql_version'  => trim( shell_exec( 'mysql --version' ) ),
 	'system_utils'   => array(),
 	'os_name'        => trim( shell_exec( 'uname -s' ) ),
 	'os_version'     => trim( shell_exec( 'uname -r' ) ),
@@ -219,10 +228,9 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve
 	\$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();
+//\$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();
 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;
