Skip to content

Commit 0912525

Browse files
authored
Merge pull request #1995 from greg0ire/no-url-override
Remove URL override feature
2 parents 4207909 + 8e0fb13 commit 0912525

File tree

10 files changed

+6
-195
lines changed

10 files changed

+6
-195
lines changed

UPGRADE-3.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ have been removed:
6060

6161
Use `doctrine.dbal.default_table_options.collation` instead.
6262

63+
### The `doctrine.dbal.override_url` option is removed
64+
65+
There is no replacement for this option.
66+
6367
### Controller resolver auto mapping can no longer be configured
6468

6569
The `doctrine.orm.controller_resolver.auto_mapping` option now only accepts `false` as value, to disallow the usage of the controller resolver auto mapping feature by default. The configuration option will be fully removed in 4.0.

docs/en/configuration.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -814,15 +814,6 @@ Doctrine DBAL Configuration
814814
accept, converted to the XML or YAML naming standards that Symfony
815815
enforces. See the Doctrine `DBAL documentation`_ for more information.
816816

817-
.. note::
818-
819-
When specifying a ``url`` parameter, any information extracted from that
820-
URL will override explicitly set parameters unless ``override_url`` is set
821-
to ``true``. An example database URL would be
822-
``mysql://snoopy:redbaron@localhost/baseball``, and any explicitly set driver,
823-
user, password and dbname parameter would be overridden by this URL.
824-
See the Doctrine `DBAL documentation`_ for more information.
825-
826817
Besides default Doctrine options, there are some Symfony-related ones that you
827818
can configure. The following block shows all possible configuration keys:
828819

src/ConnectionFactory.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use function array_merge;
2121
use function class_exists;
2222
use function is_subclass_of;
23-
use function trigger_deprecation;
2423

2524
use const PHP_EOL;
2625

@@ -69,14 +68,6 @@ public function createConnection(
6968
$this->initializeTypes();
7069
}
7170

72-
$overriddenOptions = [];
73-
/** @phpstan-ignore isset.offset (We should adjust when https://github.com/phpstan/phpstan/issues/12414 is fixed) */
74-
if (isset($params['connection_override_options'])) {
75-
trigger_deprecation('doctrine/doctrine-bundle', '2.4', 'The "connection_override_options" connection parameter is deprecated');
76-
$overriddenOptions = $params['connection_override_options'];
77-
unset($params['connection_override_options']);
78-
}
79-
8071
$params = $this->parseDatabaseUrl($params);
8172

8273
// URL support for PrimaryReplicaConnection
@@ -91,25 +82,22 @@ public function createConnection(
9182
}
9283

9384
/** @phpstan-ignore-next-line We should adjust when https://github.com/phpstan/phpstan/issues/12414 is fixed */
94-
if (! isset($params['pdo']) && (! isset($params['charset']) || $overriddenOptions || isset($params['dbname_suffix']))) {
85+
if (! isset($params['pdo']) && (! isset($params['charset']) || isset($params['dbname_suffix']))) {
9586
$wrapperClass = null;
9687

9788
if (isset($params['wrapperClass'])) {
9889
if (! is_subclass_of($params['wrapperClass'], Connection::class)) {
9990
if (class_exists(InvalidWrapperClass::class)) {
10091
throw InvalidWrapperClass::new($params['wrapperClass']);
10192
}
102-
103-
/* @phpstan-ignore staticMethod.notFound */
104-
throw DBALException::invalidWrapperClass($params['wrapperClass']);
10593
}
10694

10795
$wrapperClass = $params['wrapperClass'];
10896
$params['wrapperClass'] = null;
10997
}
11098

11199
$connection = DriverManager::getConnection($params, $config);
112-
$params = $this->addDatabaseSuffix(array_merge($connection->getParams(), $overriddenOptions));
100+
$params = $this->addDatabaseSuffix($connection->getParams());
113101
$driver = $connection->getDriver();
114102
$platform = $driver->getDatabasePlatform(new StaticServerVersionProvider(
115103
$params['serverVersion'] ?? $params['primary']['serverVersion'] ?? '',

src/DependencyInjection/Configuration.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,6 @@ private function configureDbalDriverNode(ArrayNodeDefinition $node): void
303303
->scalarNode('port')->info('Defaults to null at runtime.')->end()
304304
->scalarNode('user')->info('Defaults to "root" at runtime.')->end()
305305
->scalarNode('password')->info('Defaults to null at runtime.')->end()
306-
->booleanNode('override_url')->setDeprecated(
307-
'doctrine/doctrine-bundle',
308-
'2.4',
309-
'The "doctrine.dbal.override_url" configuration key is deprecated.',
310-
)->end()
311306
->scalarNode('dbname_suffix')->info('Adds the given suffix to the configured database name, this option has no effects for the SQLite platform')->end()
312307
->scalarNode('application_name')->end()
313308
->scalarNode('charset')->end()

src/DependencyInjection/DoctrineExtension.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
5858
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
5959

60-
use function array_intersect_key;
6160
use function array_keys;
6261
use function array_merge;
6362
use function class_exists;
@@ -338,11 +337,6 @@ protected function getConnectionOptions(array $connection): array
338337
'password' => null,
339338
];
340339

341-
if ($options['override_url'] ?? false) {
342-
$options['connection_override_options'] = array_intersect_key($options, ['dbname' => null] + $connectionDefaults);
343-
}
344-
345-
unset($options['override_url']);
346340
unset($options['schema_manager_factory']);
347341

348342
$options += $connectionDefaults;

tests/ConnectionFactoryTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
1010
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
1111

12-
use function array_intersect_key;
13-
1412
class ConnectionFactoryTest extends TestCase
1513
{
1614
use VerifyDeprecations;
@@ -61,29 +59,6 @@ public function testDefaultCollationMySql(): void
6159
);
6260
}
6361

64-
/** @group legacy */
65-
public function testConnectionOverrideOptions(): void
66-
{
67-
$params = [
68-
'dbname' => 'main_test',
69-
'host' => 'db_test',
70-
'port' => 5432,
71-
'user' => 'tester',
72-
'password' => 'wordpass',
73-
];
74-
75-
/** @psalm-suppress InvalidArgument We should adjust when https://github.com/vimeo/psalm/issues/8984 is fixed */
76-
$connection = (new ConnectionFactory([]))->createConnection(
77-
[
78-
'url' => 'mysql://root:password@database:3306/main?serverVersion=mariadb-12.1.1',
79-
'connection_override_options' => $params,
80-
],
81-
$this->configuration,
82-
);
83-
84-
$this->assertEquals($params, array_intersect_key($connection->getParams(), $params));
85-
}
86-
8762
public function testConnectionCharsetFromUrl(): void
8863
{
8964
/** @psalm-suppress InvalidArgument Need to be compatible with DBAL < 4, which still has `$params['url']` */

tests/DependencyInjection/AbstractDoctrineExtensionTestCase.php

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
use Symfony\Component\Security\Core\User\UserInterface;
3333

3434
use function array_filter;
35-
use function array_intersect_key;
3635
use function array_keys;
3736
use function array_values;
3837
use function assert;
@@ -130,47 +129,6 @@ public function testDbalLoadFromXmlSingleConnections(): void
130129
$this->assertEquals('9.4.0', $config['serverVersion']);
131130
}
132131

133-
/** @group legacy */
134-
public function testDbalLoadUrlOverride(): void
135-
{
136-
$container = $this->loadContainer('dbal_allow_url_override');
137-
$config = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);
138-
139-
$this->assertSame('mysql://root:password@database:3306/main?serverVersion=mariadb-12.1.1', $config['url']);
140-
141-
$expectedOverrides = [
142-
'dbname' => 'main_test',
143-
'user' => 'tester',
144-
'password' => 'wordpass',
145-
'host' => 'localhost',
146-
'port' => 4321,
147-
];
148-
149-
$this->assertEquals($expectedOverrides, array_intersect_key($config, $expectedOverrides));
150-
$this->assertSame($expectedOverrides, $config['connection_override_options']);
151-
$this->assertFalse(isset($config['override_url']));
152-
}
153-
154-
/** @group legacy */
155-
public function testDbalLoadPartialUrlOverrideSetsDefaults(): void
156-
{
157-
$container = $this->loadContainer('dbal_allow_partial_url_override');
158-
$config = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);
159-
160-
$expectedDefaults = [
161-
'host' => 'localhost',
162-
'user' => 'root',
163-
'password' => null,
164-
'port' => null,
165-
];
166-
167-
$this->assertEquals($expectedDefaults, array_intersect_key($config, $expectedDefaults));
168-
$this->assertSame('mysql://root:password@database:3306/main?serverVersion=mariadb-12.1.1', $config['url']);
169-
$this->assertCount(1, $config['connection_override_options']);
170-
$this->assertSame('main_test', $config['connection_override_options']['dbname']);
171-
$this->assertFalse(isset($config['override_url']));
172-
}
173-
174132
public function testDbalDbnameSuffix(): void
175133
{
176134
$container = $this->loadContainer('dbal_dbname_suffix');

tests/DependencyInjection/Fixtures/config/yml/dbal_allow_partial_url_override.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/DependencyInjection/Fixtures/config/yml/dbal_allow_url_override.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/UrlOverrideTest.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)