From 7a82d82d65168fee6d4bdc2594591d61d693e0a1 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 17 Aug 2024 18:24:29 +0200 Subject: [PATCH 1/3] Avoid multiple connects in SKIPIF sections Besides checking for the ability to connect to the MySQL server, some tests require additional checks (e.g. to be able to check for the server's version) as skip condition. There is no need, though, to connect twice; instead we introduce `mysqli_connect_or_skip()` in test_helpers.inc, which `die()`s with an appropriate error message, if the connection can't be established, or returns the connection link otherwise. --- ext/mysqli/tests/045.phpt | 6 ++---- ext/mysqli/tests/gh9590.phpt | 7 ++----- ext/mysqli/tests/mysqli_begin_transaction.phpt | 8 ++------ ext/mysqli/tests/mysqli_change_user_old.phpt | 8 ++------ ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt | 5 ++--- ext/mysqli/tests/mysqli_query_unicode.phpt | 6 ++---- ext/mysqli/tests/mysqli_real_escape_string_big5.phpt | 10 ++-------- .../tests/mysqli_real_escape_string_eucjpms.phpt | 10 ++-------- ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt | 10 ++-------- ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt | 10 ++-------- ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt | 10 ++-------- ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt | 9 ++------- ext/mysqli/tests/test_setup/test_helpers.inc | 4 ++++ 13 files changed, 28 insertions(+), 75 deletions(-) diff --git a/ext/mysqli/tests/045.phpt b/ext/mysqli/tests/045.phpt index ec70cb9877fbf..8284812a7991f 100644 --- a/ext/mysqli/tests/045.phpt +++ b/ext/mysqli/tests/045.phpt @@ -4,10 +4,8 @@ mysqli_stmt_bind_result (SHOW) mysqli --SKIPIF-- errno, $link->error)); ?> diff --git a/ext/mysqli/tests/mysqli_change_user_old.phpt b/ext/mysqli/tests/mysqli_change_user_old.phpt index fd418220ae80d..980bc533c4c06 100644 --- a/ext/mysqli/tests/mysqli_change_user_old.phpt +++ b/ext/mysqli/tests/mysqli_change_user_old.phpt @@ -4,12 +4,8 @@ mysqli_change_user(), MySQL < 5.6 mysqli --SKIPIF-- = 50600 && mysqli_get_server_version($link) < 10_00_00) die("SKIP For MySQL < 5.6.0"); ?> diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt index 9f3197b903c4b..ff1cbb7a5bc90 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt @@ -4,9 +4,8 @@ mysqli_fetch_assoc() - BIT mysqli --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- query("SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'InnoDB'"); From 0e334fe1ea12861cddb60161765913517da5e869 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 18 Aug 2024 11:30:39 +0200 Subject: [PATCH 2/3] return or die Co-authored-by: Kamil Tekiela --- ext/mysqli/tests/test_setup/test_helpers.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/mysqli/tests/test_setup/test_helpers.inc b/ext/mysqli/tests/test_setup/test_helpers.inc index fdafc36d19dcb..c9ab401e75683 100644 --- a/ext/mysqli/tests/test_setup/test_helpers.inc +++ b/ext/mysqli/tests/test_setup/test_helpers.inc @@ -112,11 +112,10 @@ function mysqli_check_skip_test(): void { } function mysqli_connect_or_skip() { try { - default_mysqli_connect(); + return default_mysqli_connect(); } catch (\mysqli_sql_exception) { die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error())); } - return $link; } function have_innodb(mysqli $link): bool { $res = $link->query("SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'InnoDB'"); From c8003b4a1331d4c7186dd7143042eff20ff23b2a Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 18 Aug 2024 11:32:25 +0200 Subject: [PATCH 3/3] Remove broken, but unnecessary UTF-8 support check --- ext/mysqli/tests/mysqli_query_unicode.phpt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/mysqli/tests/mysqli_query_unicode.phpt b/ext/mysqli/tests/mysqli_query_unicode.phpt index 1d2286115aa9d..6f01aff57084f 100644 --- a/ext/mysqli/tests/mysqli_query_unicode.phpt +++ b/ext/mysqli/tests/mysqli_query_unicode.phpt @@ -4,10 +4,7 @@ mysqli_query() - unicode (cyrillic) mysqli --SKIPIF-- --FILE--