Skip to content

Commit ccfa589

Browse files
Merge pull request #176 from grooverdan/mysql
Use mysql version from server rather than mysql --version
2 parents fb00cbe + 1b1398b commit ccfa589

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

functions.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,16 @@ function upload_results( $results, $rev, $message, $env, $api_key ) {
280280
* @uses class_exists() to check for the availability of the Imagick and Gmagick classes for version detection.
281281
*/
282282
function get_env_details() {
283+
$WPT_DB_HOST = getenv( 'WPT_DB_HOST' ) ? : 'localhost';
284+
$WPT_DB_USER = getenv( 'WPT_DB_USER' );
285+
$WPT_DB_PASSWORD = getenv( 'WPT_DB_PASSWORD' );
286+
$WPT_DB_NAME = getenv( 'WPT_DB_NAME' );
283287
$env = array(
284288
'php_version' => phpversion(),
285289
'php_modules' => array(),
286290
'gd_info' => extension_loaded( 'gd' ) ? gd_info() : array(),
287291
'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : array(),
288292
'system_utils' => array(),
289-
'mysql_version' => trim( shell_exec( 'mysql --version' ) ),
290293
'os_name' => trim( shell_exec( 'uname -s' ) ),
291294
'os_version' => trim( shell_exec( 'uname -r' ) ),
292295
);
@@ -333,6 +336,10 @@ function get_env_details() {
333336
$curl_bits = explode( PHP_EOL, str_replace( 'curl ', '', shell_exec( 'curl --version' ) ) );
334337
$curl = array_shift( $curl_bits );
335338
$env['system_utils']['curl'] = trim( $curl );
339+
$mysqli = new mysqli($WPT_DB_HOST, $WPT_DB_USER, $WPT_DB_PASSWORD, $WPT_DB_NAME);
340+
$env['mysql_version'] = $mysqli->query("SELECT VERSION()")->fetch_row()[0];
341+
$mysqli->close();
342+
336343
if ( class_exists( 'Imagick' ) ) {
337344
$imagick = new Imagick();
338345
$version = $imagick->getVersion();

prepare.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@
161161
'gd_info' => extension_loaded( 'gd' ) ? gd_info() : array(),
162162
'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : array(),
163163
'system_utils' => array(),
164-
'mysql_version' => trim( shell_exec( 'mysql --version' ) ),
165164
'os_name' => trim( shell_exec( 'uname -s' ) ),
166165
'os_version' => trim( shell_exec( 'uname -r' ) ),
167166
);
@@ -220,6 +219,10 @@
220219
\$env['system_utils']['graphicsmagick'] = \$version[1];
221220
}
222221
\$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) );
222+
223+
\$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
224+
\$env['mysql_version'] = \$mysqli->query("SELECT VERSION()")->fetch_row()[0];
225+
\$mysqli->close();
223226
file_put_contents( __DIR__ . '/tests/phpunit/build/logs/env.json', json_encode( \$env, JSON_PRETTY_PRINT ) );
224227
if ( 'cli' === php_sapi_name() && defined( 'WP_INSTALLING' ) && WP_INSTALLING ) {
225228
echo PHP_EOL;

0 commit comments

Comments
 (0)