Skip to content

Commit

Permalink
refactor: drop master
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored and ostrolucky committed Apr 14, 2022
1 parent 035c919 commit 4f4387c
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 15 deletions.
5 changes: 0 additions & 5 deletions Command/CreateDatabaseDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$params = $connection->getParams();

// Since doctrine/dbal 2.11 master has been replaced by primary
if (isset($params['primary'])) {
$params = $params['primary'];
}

if (isset($params['master'])) {
$params = $params['master'];
}

// Cannot inject `shard` option in parent::getDoctrineConnection
// cause it will try to connect to a non-existing database
if (isset($params['shards'])) {
Expand Down
5 changes: 0 additions & 5 deletions Command/DropDatabaseDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$params = $connection->getParams();

// Since doctrine/dbal 2.11 master has been replaced by primary
if (isset($params['primary'])) {
$params = $params['primary'];
}

if (isset($params['master'])) {
$params = $params['master'];
}

if (isset($params['shards'])) {
$shards = $params['shards'];
// Default select global
Expand Down
3 changes: 1 addition & 2 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected function getConnectionOptions(array $connection): array
}

if (! empty($options['slaves']) && ! empty($options['replica']) && ! empty($options['shards'])) {
throw new InvalidArgumentException('Sharding and master-slave connection cannot be used together');
throw new InvalidArgumentException('Sharding and primary-replica connection cannot be used together');
}

foreach (['shards', 'replica', 'slaves'] as $connectionKey) {
Expand All @@ -382,7 +382,6 @@ protected function getConnectionOptions(array $connection): array
'shardChoser' => true,
'platform' => true,
'slaves' => true,
'master' => true,
'primary' => true,
'replica' => true,
'shards' => true,
Expand Down
6 changes: 3 additions & 3 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public function testDbalDbnameSuffix(): void
$this->assertSame('_test', $config['dbname_suffix']);
}

public function testDbalLoadSingleMasterSlaveConnection(): void
public function testDbalLoadSinglePrimaryReplicaConnection(): void
{
$container = $this->loadContainer('dbal_service_single_master_slave_connection');
$container = $this->loadContainer('dbal_service_single_primary_replica_connection');
$param = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);

$this->assertEquals(PrimaryReadReplicaConnection::class, $param['wrapperClass']);
Expand All @@ -202,7 +202,7 @@ public function testDbalLoadSingleMasterSlaveConnection(): void
'unix_socket' => '/path/to/mysqld.sock',
'driverOptions' => [PDO::ATTR_STRINGIFY_FETCHES => 1],
],
$param['primary'] ?? $param['master'] // TODO: Remove 'master' support here when we require dbal >= 2.11
$param['primary']
);
$this->assertEquals(
[
Expand Down

0 comments on commit 4f4387c

Please sign in to comment.