From: Max Semenik Date: Thu, 25 Feb 2021 15:51:11 +0000 (+0300) Subject: Update mysqli tests to work with newer MySQL server X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c639d34a6e2972dce9679b474c768b434703e1a6;p=php Update mysqli tests to work with newer MySQL server * @@session.old_passwords is present only in 5.6 and 5.7. Newer versions already behave as if they have old_passwords=2. * SET PASSWORD FOR ... = PASSWORD(...) syntax was removed in 8.0. For all affected tests, versions that don't support newer SQL are already explicitly excluded with version checks. Closes GH-6729. --- diff --git a/ext/mysqli/tests/mysqli_pam_sha256.phpt b/ext/mysqli/tests/mysqli_pam_sha256.phpt index 29df5c1fde..7f94f202cc 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256.phpt @@ -45,9 +45,8 @@ if (strlen($row['Value']) < 100) { die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error)); } -if (!$link->query("SET @@session.old_passwords=2")) { - die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); -} +// Ignore errors because this variable exists only in MySQL 5.6 and 5.7 +$link->query("SET @@session.old_passwords=2"); $link->query('DROP USER shatest'); $link->query("DROP USER shatest@localhost"); @@ -58,8 +57,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); } -if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || - !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { +if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) { die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); } diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt index 90f9a255a6..f67d57ca75 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt @@ -57,10 +57,8 @@ if (strlen($key) != fwrite($fp, $key)) { die(sprintf("skip Failed to create pub key file")); } - -if (!$link->query("SET @@session.old_passwords=2")) { - die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); -} +// Ignore errors because this variable exists only in MySQL 5.6 and 5.7 +$link->query("SET @@session.old_passwords=2"); $link->query('DROP USER shatest'); $link->query("DROP USER shatest@localhost"); @@ -71,8 +69,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); } -if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || - !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { +if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) { die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); } diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt index 1493c37737..a76feebf9f 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt @@ -54,10 +54,8 @@ if (strlen($row['Value']) != fwrite($fp, $row['Value'])) { die(sprintf("skip Failed to create pub key file")); } - -if (!$link->query("SET @@session.old_passwords=2")) { - die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); -} +// Ignore errors because this variable exists only in MySQL 5.6 and 5.7 +$link->query("SET @@session.old_passwords=2"); $link->query('DROP USER shatest'); $link->query("DROP USER shatest@localhost"); @@ -68,8 +66,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); } -if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || - !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { +if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) { die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); } diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt index 5c55821b8a..9b2109d754 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt @@ -54,10 +54,8 @@ if (strlen($row['Value']) != fwrite($fp, $row['Value'])) { die(sprintf("skip Failed to create pub key file")); } - -if (!$link->query("SET @@session.old_passwords=2")) { - die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); -} +// Ignore errors because this variable exists only in MySQL 5.6 and 5.7 +$link->query("SET @@session.old_passwords=2"); $link->query('DROP USER shatest'); $link->query("DROP USER shatest@localhost"); @@ -68,8 +66,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); } -if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || - !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { +if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) { die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); }