Skip to content

Commit 266d3e6

Browse files
committed
Merge branch '3.10.x' into 4.3.x
* 3.10.x: Document the PDO subclasses backport (#7137) Downgrade PHP for the DB2 workflow (#7134) Workaround for MySQL 8.4 and unknown users (#7136) Leverage PHP 8.4 PDO classes, fix PHP 8.5 deprecation (#7132) Run tests on MySQL 8.4 LTS and 9.4 (#7133)
2 parents d5a5a21 + 3e46b11 commit 266d3e6

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,22 @@ jobs:
189189
mysql-version:
190190
- "5.7"
191191
- "8.0" # We have code specific to ^8.0
192-
- "9.3"
192+
- "8.4" # LTS
193+
- "9.4"
193194
extension:
194195
- "mysqli"
195196
- "pdo_mysql"
196197
include:
197198
- config-file-suffix: "-tls"
198199
php-version: "8.2"
199-
mysql-version: "9.1"
200+
mysql-version: "9.4"
200201
extension: "mysqli"
201202
- config-file-suffix: "-stringify_fetches"
202203
php-version: "8.2"
203-
mysql-version: "9.1"
204+
mysql-version: "9.4"
204205
extension: "pdo_mysql"
205206
- php-version: "8.2"
206-
mysql-version: "9.1"
207+
mysql-version: "9.4"
207208
extension: "mysqli"
208209

209210
phpunit-mssql:
@@ -246,7 +247,8 @@ jobs:
246247
php-version:
247248
- "8.2"
248249
- "8.3"
249-
- "8.4"
250+
# The DB2 workflow currently segfaults with PHP 8.4
251+
# - "8.4"
250252

251253
development-deps:
252254
name: "PHPUnit with PDO_SQLite and development dependencies"

UPGRADE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,16 @@ The following methods have been removed.
13541354

13551355
# Upgrade to 3.10
13561356

1357+
## Support for new PDO subclasses on PHP 8.4
1358+
1359+
In 3.10.2, we've backported support for new PDO subclasses introduced in PHP 8.4 because not using them
1360+
could trigger deprecation warnings under certain circumstances in PHP 8.5.
1361+
1362+
On PHP 8.4, if you call `getNativeConnection()` on a connection established through one of the PDO drivers,
1363+
you will get an instance of the new PDO subclasses, e.g. `Pdo\Mysql` or `Pdo\Pgsql` instead of just `PDO`.
1364+
1365+
## Optional `doctrine/cache` dependency
1366+
13571367
The `doctrine/cache` package is now an optional dependency. If you are using the
13581368
`Doctrine\DBAL\Cache` classes, you need to require the `doctrine/cache` package
13591369
explicitly.

src/Driver/API/MySQL/ExceptionConverter.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
2323
use Doctrine\DBAL\Query;
2424

25+
use function str_contains;
26+
2527
/** @internal */
2628
final class ExceptionConverter implements ExceptionConverterInterface
2729
{
@@ -31,6 +33,15 @@ final class ExceptionConverter implements ExceptionConverterInterface
3133
*/
3234
public function convert(Exception $exception, ?Query $query): DriverException
3335
{
36+
if (
37+
$exception->getCode() === 1524
38+
&& str_contains($exception->getMessage(), 'Plugin \'mysql_native_password\' is not loaded')
39+
) {
40+
// Workaround for MySQL 8.4 if we request an unknown user.
41+
// https://bugs.mysql.com/bug.php?id=114876
42+
return new ConnectionException($exception, $query);
43+
}
44+
3445
return match ($exception->getCode()) {
3546
1008 => new DatabaseDoesNotExist($exception, $query),
3647
1213 => new DeadlockException($exception, $query),

src/Driver/PDO/PgSQL/Driver.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
use Doctrine\DBAL\Driver\PDO\Exception\InvalidConfiguration;
1111
use Doctrine\DBAL\Driver\PDO\PDOConnect;
1212
use PDO;
13+
use Pdo\Pgsql;
1314
use PDOException;
1415
use SensitiveParameter;
1516

1617
use function is_string;
1718

19+
use const PHP_VERSION_ID;
20+
1821
final class Driver extends AbstractPostgreSQLDriver
1922
{
2023
use PDOConnect;
@@ -52,11 +55,11 @@ public function connect(
5255
throw Exception::new($exception);
5356
}
5457

55-
if (
56-
! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES])
57-
|| $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true
58-
) {
59-
$pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
58+
$disablePreparesAttr = PHP_VERSION_ID >= 80400
59+
? Pgsql::ATTR_DISABLE_PREPARES
60+
: PDO::PGSQL_ATTR_DISABLE_PREPARES;
61+
if ($driverOptions[$disablePreparesAttr] ?? true) {
62+
$pdo->setAttribute($disablePreparesAttr, true);
6063
}
6164

6265
$connection = new Connection($pdo);

0 commit comments

Comments
 (0)