Skip to content

Commit

Permalink
Merge pull request #176 from grooverdan/mysql
Browse files Browse the repository at this point in the history
Use mysql version from server rather than mysql --version
  • Loading branch information
javiercasares committed Feb 7, 2024
2 parents fb00cbe + 1b1398b commit ccfa589
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,16 @@ 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' );
$env = array(
'php_version' => phpversion(),
'php_modules' => array(),
'gd_info' => extension_loaded( 'gd' ) ? gd_info() : array(),
'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 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' ) ),
);
Expand Down Expand Up @@ -333,6 +336,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();
Expand Down
5 changes: 4 additions & 1 deletion prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
'gd_info' => extension_loaded( 'gd' ) ? gd_info() : array(),
'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 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' ) ),
);
Expand Down Expand Up @@ -220,6 +219,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;
Expand Down

0 comments on commit ccfa589

Please sign in to comment.