Skip to content

Commit

Permalink
Deprecate MasterSlaveConnection class
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
greg0ire committed Jun 7, 2020
1 parent 3cfb57d commit 5149e52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
11 changes: 11 additions & 0 deletions lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,6 +57,8 @@
*
* Instantiation through the DriverManager looks like:
*
* @deprecated use regular connections instead
*
* @example
*
* $conn = DriverManager::getConnection(array(
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit 5149e52

Please sign in to comment.