Skip to content

Commit c869712

Browse files
committed
only override if there is a url to override
1 parent 4270459 commit c869712

10 files changed

+11
-28
lines changed

ConnectionFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public function createConnection(array $params, Configuration $config = null, Ev
4848
$allowOverrideUrl = $params['override_url'] ?? false;
4949
unset($params['override_url']);
5050

51-
if (! $allowOverrideUrl) {
51+
if (! $allowOverrideUrl && isset($params['url'])) {
5252
trigger_deprecation(
5353
'doctrine/DoctrineBundle',
5454
'2.3.0',
5555
'Setting doctrine.dbal.override_url to true allows you to override the dsn parameters set in doctrine.dbal.url. This will be the default behavior in future versions.'
5656
);
5757
}
5858

59-
if (! isset($params['pdo']) && (! isset($params['charset']) || $allowOverrideUrl)) {
59+
if (! isset($params['pdo']) && (! isset($params['charset']) || ($allowOverrideUrl && isset($params['url'])))) {
6060
$originalParams = $params;
6161
$wrapperClass = null;
6262

Tests/ConnectionFactoryTest.php

+2-9
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ public function testContainer(): void
1818
{
1919
$typesConfig = [];
2020
$factory = new ConnectionFactory($typesConfig);
21-
$params = [
22-
'driverClass' => FakeDriver::class,
23-
'override_url' => true,
24-
];
21+
$params = ['driverClass' => FakeDriver::class];
2522
$config = null;
2623
$eventManager = null;
2724
$mappingTypes = [0];
@@ -55,7 +52,6 @@ public function testDefaultCharset(): void
5552
$params = [
5653
'driverClass' => FakeDriver::class,
5754
'wrapperClass' => FakeConnection::class,
58-
'override_url' => true,
5955
];
6056

6157
$creationCount = FakeConnection::$creationCount;
@@ -69,10 +65,7 @@ public function testDefaultCharset(): void
6965
public function testDefaultCharsetMySql(): void
7066
{
7167
$factory = new ConnectionFactory([]);
72-
$params = [
73-
'driver' => 'pdo_mysql',
74-
'override_url' => true,
75-
];
68+
$params = ['driver' => 'pdo_mysql'];
7669

7770
$connection = $factory->createConnection($params);
7871

Tests/CustomIdGeneratorTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public function testRepositoryServiceWiring(): void
5656
'dbal' => [
5757
'driver' => 'pdo_sqlite',
5858
'charset' => 'UTF8',
59-
'override_url' => true,
6059
],
6160
'orm' => [
6261
'mappings' => [

Tests/DependencyInjection/Fixtures/TestKernel.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
3333
$container->loadFromExtension('framework', ['secret' => 'F00']);
3434

3535
$container->loadFromExtension('doctrine', [
36-
'dbal' => [
37-
'driver' => 'pdo_sqlite',
38-
'override_url' => true,
39-
],
36+
'dbal' => ['driver' => 'pdo_sqlite'],
4037
'orm' => [
4138
'auto_generate_proxy_classes' => true,
4239
'mappings' => [

Tests/DependencyInjection/Fixtures/config/xml/dbal_schema_filter.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
<config>
1010
<dbal default-connection="connection1">
11-
<connection name="connection1" schema-filter="~^(?!t_)~" override-url="true" />
12-
<connection name="connection2" override-url="true" />
13-
<connection name="connection3" override-url="true" />
11+
<connection name="connection1" schema-filter="~^(?!t_)~" />
12+
<connection name="connection2" />
13+
<connection name="connection3" />
1414
</dbal>
1515
</config>
1616
</srv:container>

Tests/DependencyInjection/Fixtures/config/xml/orm_filters.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<config>
1010
<dbal default-connection="default">
11-
<connection name="default" dbname="db" override-url="true" />
11+
<connection name="default" dbname="db" />
1212
</dbal>
1313

1414
<orm>

Tests/DependencyInjection/Fixtures/config/yml/dbal_schema_filter.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ doctrine:
33
default_connection: connection1
44
connections:
55
connection1:
6-
override_url: true
76
schema_filter: ~^(?!t_)~
8-
connection2:
9-
override_url: true
10-
connection3:
11-
override_url: true
7+
connection2: []
8+
connection3: []

Tests/DependencyInjection/Fixtures/config/yml/orm_filters.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ doctrine:
33
default_connection: default
44
connections:
55
default:
6-
override_url: true
76
dbname: db
87

98
orm:

Tests/ServiceRepositoryTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public function testRepositoryServiceWiring(): void
6161
'dbal' => [
6262
'driver' => 'pdo_sqlite',
6363
'charset' => 'UTF8',
64-
'override_url' => true,
6564
],
6665
'orm' => [
6766
'mappings' => [

Tests/TestCase.php

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public function createXmlBundleTestContainer(): ContainerBuilder
3838
'driver' => 'pdo_mysql',
3939
'charset' => 'UTF8',
4040
'platform-service' => 'my.platform',
41-
'override_url' => true,
4241
],
4342
],
4443
'default_connection' => 'default',

0 commit comments

Comments
 (0)