Skip to content

Commit c639d34

Browse files
MaxSemnikic
authored andcommitted
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.
1 parent 0074a1d commit c639d34

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

ext/mysqli/tests/mysqli_pam_sha256.phpt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ if (strlen($row['Value']) < 100) {
4545
die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
4646
}
4747

48-
if (!$link->query("SET @@session.old_passwords=2")) {
49-
die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
50-
}
48+
// Ignore errors because this variable exists only in MySQL 5.6 and 5.7
49+
$link->query("SET @@session.old_passwords=2");
5150

5251
$link->query('DROP USER shatest');
5352
$link->query("DROP USER shatest@localhost");
@@ -58,8 +57,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
5857
die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
5958
}
6059

61-
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
62-
!$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
60+
if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') ||
61+
!$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) {
6362
die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
6463
}
6564

ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ if (strlen($key) != fwrite($fp, $key)) {
5757
die(sprintf("skip Failed to create pub key file"));
5858
}
5959

60-
61-
if (!$link->query("SET @@session.old_passwords=2")) {
62-
die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
63-
}
60+
// Ignore errors because this variable exists only in MySQL 5.6 and 5.7
61+
$link->query("SET @@session.old_passwords=2");
6462

6563
$link->query('DROP USER shatest');
6664
$link->query("DROP USER shatest@localhost");
@@ -71,8 +69,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
7169
die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
7270
}
7371

74-
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
75-
!$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
72+
if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') ||
73+
!$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) {
7674
die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
7775
}
7876

ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ if (strlen($row['Value']) != fwrite($fp, $row['Value'])) {
5454
die(sprintf("skip Failed to create pub key file"));
5555
}
5656

57-
58-
if (!$link->query("SET @@session.old_passwords=2")) {
59-
die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
60-
}
57+
// Ignore errors because this variable exists only in MySQL 5.6 and 5.7
58+
$link->query("SET @@session.old_passwords=2");
6159

6260
$link->query('DROP USER shatest');
6361
$link->query("DROP USER shatest@localhost");
@@ -68,8 +66,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
6866
die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
6967
}
7068

71-
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
72-
!$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
69+
if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') ||
70+
!$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) {
7371
die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
7472
}
7573

ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ if (strlen($row['Value']) != fwrite($fp, $row['Value'])) {
5454
die(sprintf("skip Failed to create pub key file"));
5555
}
5656

57-
58-
if (!$link->query("SET @@session.old_passwords=2")) {
59-
die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
60-
}
57+
// Ignore errors because this variable exists only in MySQL 5.6 and 5.7
58+
$link->query("SET @@session.old_passwords=2");
6159

6260
$link->query('DROP USER shatest');
6361
$link->query("DROP USER shatest@localhost");
@@ -68,8 +66,8 @@ if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
6866
die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
6967
}
7068

71-
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
72-
!$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
69+
if (!$link->query('SET PASSWORD FOR shatest@"%" = "shatest"') ||
70+
!$link->query('SET PASSWORD FOR shatest@"localhost" = "shatest"')) {
7371
die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
7472
}
7573

0 commit comments

Comments
 (0)