Skip to content

Commit f0b0d40

Browse files
Copilotswissspidy
andcommitted
Address code review feedback: improve error handling and fix typo
Co-authored-by: swissspidy <[email protected]>
1 parent 8c404ea commit f0b0d40

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

bin/install-package-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,5 @@ else
179179
install_mysql_db_lower_than_8_0
180180
fi
181181

182-
echo "Succesfully prepared the database for running tests."
182+
echo "Successfully prepared the database for running tests."
183183
echo "This command does not have to be run again."

utils/behat-tags.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ function version_tags(
4343
function get_db_type_and_version() {
4444
// Detect which client binary is available.
4545
$client_binary = null;
46+
$output = array();
4647
exec( 'command -v mysql 2>/dev/null', $output, $mysql_exit_code );
4748
if ( 0 === $mysql_exit_code ) {
4849
$client_binary = 'mysql';
4950
} else {
51+
$output = array();
5052
exec( 'command -v mariadb 2>/dev/null', $output, $mariadb_exit_code );
5153
if ( 0 === $mariadb_exit_code ) {
5254
$client_binary = 'mariadb';
@@ -88,7 +90,15 @@ function get_db_type_and_version() {
8890
$pass_arg
8991
);
9092

91-
$version_string = exec( $cmd );
93+
$output = array();
94+
$return_code = 0;
95+
exec( $cmd, $output, $return_code );
96+
$version_string = isset( $output[0] ) ? $output[0] : '';
97+
98+
// If the connection failed, return defaults.
99+
if ( 0 !== $return_code || empty( $version_string ) ) {
100+
return array( 'type' => 'mysql', 'version' => '' );
101+
}
92102

93103
// Detect database type from server version string.
94104
$db_type = 'mysql';

0 commit comments

Comments
 (0)