From 5149e528c0d556ffe4bc68ee662047fd29e92f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 7 Jun 2020 22:09:53 +0200 Subject: [PATCH] Deprecate MasterSlaveConnection class Not only is the terminology needlessly hurtful, the design is a very leaky abstraction, and users are better off using regular connections and managing them themselves explicitly. --- UPGRADE.md | 5 +++++ .../DBAL/Connections/MasterSlaveConnection.php | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 2d1f52303a6..5ab9ed7112f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 2.11 +## Deprecated `MasterSlaveConnection` + +The naming is offensive, the implementation very questionable. Use each +endpoint connection explicitly. + ## Deprecated `ArrayStatement` and `ResultCacheStatement` classes. The `ArrayStatement` and `ResultCacheStatement` classes are deprecated. In a future major release they will be renamed and marked internal as implementation details of the caching layer. diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 9362bc0c636..d3d4951500b 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -15,6 +15,10 @@ use function assert; use function count; use function func_get_args; +use function sprintf; +use function trigger_error; + +use const E_USER_DEPRECATED; /** * Master-Slave Connection @@ -53,6 +57,8 @@ * * Instantiation through the DriverManager looks like: * + * @deprecated use regular connections instead + * * @example * * $conn = DriverManager::getConnection(array( @@ -93,6 +99,11 @@ class MasterSlaveConnection extends Connection */ public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) { + @trigger_error(sprintf( + 'Class "%s" is deprecated since doctrine/dbal 2.11 and will be removed in 3.0', + self::class + ), E_USER_DEPRECATED); + if (! isset($params['slaves'], $params['master'])) { throw new InvalidArgumentException('master or slaves configuration missing'); }