Skip to content

Commit 0ab53f1

Browse files
committed
Bring back test case support for older MySQL versions
These test cases have recently been adjusted to work with MySQL 8[1], but some older, but still supported database versions, such as MySQL 5.6, still need the password to be sent hashed, so we fall back to using `PASSWORD()`, if the `SET PASSWORD` query fails without it. [1] <http://git.php.net/?p=php-src.git;a=commit;h=b0efd18f7844da29931737b8a1cf461c7493e168>.
1 parent 1ef8d5d commit 0ab53f1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ext/mysqli/tests/mysqli_expire_password.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%
6161
$link->query("SELECT id FROM test WHERE id = 1");
6262
printf("[002] Connect should fail, [%d] %s\n", $link->errno, $link->error);
6363
}
64-
6564
/* explicitly requesting default */
6665
$link = mysqli_init();
6766
$link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 0);
@@ -92,7 +91,9 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%
9291
printf("[007] Cannot connect [%d] %s\n",
9392
mysqli_connect_errno(), mysqli_connect_error());
9493
} else {
95-
$link->query("SET PASSWORD='expiretest'");
94+
if (!$link->query("SET PASSWORD='expiretest'")) {
95+
$link->query("SET PASSWORD=PASSWORD('expiretest')");
96+
}
9697
printf("[008] Connect allowed, pw set, [%d] %s\n", $link->errno, $link->error);
9798
if ($res = $link->query("SELECT id FROM test WHERE id = 1"))
9899
var_dump($res->fetch_assoc());

ext/mysqli/tests/mysqli_pconn_max_links.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ mysqli.rollback_on_cached_plink=1
9292
var_dump($row);
9393

9494
// change the password for the second DB user and kill the persistent connection
95-
if (!mysqli_query($link, 'SET PASSWORD FOR pcontest = "newpass"') ||
95+
if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest = "newpass"') &&
96+
!mysqli_query($link, 'SET PASSWORD FOR pcontest = PASSWORD("newpass")'))||
9697
!mysqli_query($link, 'FLUSH PRIVILEGES'))
9798
printf("[005] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
9899

99100
// change the password for the second DB user and kill the persistent connection
100-
if (!mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = "newpass"') ||
101+
if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = "newpass"') &&
102+
!mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = PASSWORD("newpass")')) ||
101103
!mysqli_query($link, 'FLUSH PRIVILEGES'))
102104
printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
103105

0 commit comments

Comments
 (0)