Skip to content

Commit 821610f

Browse files
committed
Merge branch '4.5.x' into 5.0.x
2 parents 69cae42 + c997965 commit 821610f

File tree

9 files changed

+70
-9
lines changed

9 files changed

+70
-9
lines changed

UPGRADE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ all drivers and middleware.
417417
* Upgrade to MySQL 8.0 or later.
418418
* Upgrade to Postgres 12 or later.
419419

420+
# Upgrade to 4.5
421+
422+
## Deprecated `dbname` connection parameter for `oci8` and `pdo_oci` connections.
423+
424+
Using the `dbname` connection parameter for `oci8` and `pdo_oci` connections has been deprecated. Use `servicename` or
425+
`sid` instead.
426+
420427
# Upgrade to 4.4
421428

422429
## Deprecated using current date, time and timestamp SQL expressions as default values

ci/github/phpunit/oci8-21.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
<var name="db_host" value="localhost"/>
1818
<var name="db_user" value="doctrine"/>
1919
<var name="db_password" value="oracle"/>
20-
<var name="db_dbname" value="XE"/>
2120
<var name="db_charset" value="AL32UTF8" />
2221

2322
<var name="tmpdb_driver" value="oci8"/>
2423
<var name="tmpdb_host" value="localhost"/>
2524
<var name="tmpdb_user" value="system"/>
2625
<var name="tmpdb_password" value="oracle"/>
27-
<var name="tmpdb_dbname" value="XE"/>
2826
</php>
2927

3028
<testsuites>

ci/github/phpunit/oci8.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
<var name="db_host" value="localhost"/>
1818
<var name="db_user" value="doctrine"/>
1919
<var name="db_password" value="oracle"/>
20-
<var name="db_dbname" value="FREE"/>
2120
<var name="db_charset" value="AL32UTF8" />
2221

2322
<var name="tmpdb_driver" value="oci8"/>
2423
<var name="tmpdb_host" value="localhost"/>
2524
<var name="tmpdb_user" value="system"/>
2625
<var name="tmpdb_password" value="oracle"/>
27-
<var name="tmpdb_dbname" value="FREE"/>
2826
</php>
2927

3028
<testsuites>

ci/github/phpunit/pdo_oci-21.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
<var name="db_host" value="localhost"/>
1818
<var name="db_user" value="doctrine"/>
1919
<var name="db_password" value="oracle"/>
20-
<var name="db_dbname" value="XE"/>
2120
<var name="db_charset" value="AL32UTF8" />
2221

2322
<var name="tmpdb_driver" value="pdo_oci"/>
2423
<var name="tmpdb_host" value="localhost"/>
2524
<var name="tmpdb_user" value="system"/>
2625
<var name="tmpdb_password" value="oracle"/>
27-
<var name="tmpdb_dbname" value="XE"/>
2826
</php>
2927

3028
<testsuites>

ci/github/phpunit/pdo_oci.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
<var name="db_host" value="localhost"/>
1818
<var name="db_user" value="doctrine"/>
1919
<var name="db_password" value="oracle"/>
20-
<var name="db_dbname" value="FREE"/>
2120
<var name="db_charset" value="AL32UTF8" />
2221

2322
<var name="tmpdb_driver" value="pdo_oci"/>
2423
<var name="tmpdb_host" value="localhost"/>
2524
<var name="tmpdb_user" value="system"/>
2625
<var name="tmpdb_password" value="oracle"/>
27-
<var name="tmpdb_dbname" value="FREE"/>
2826
</php>
2927

3028
<testsuites>

docs/en/reference/configuration.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,11 @@ pdo_oci / oci8
302302
database.
303303
- ``host`` (string): Hostname of the database to connect to.
304304
- ``port`` (integer): Port of the database to connect to.
305-
- ``dbname`` (string): Name of the database/schema to connect to.
305+
- ``dbname`` (string): Name of the database/schema to connect to. Using this parameter is deprecated.
306306
- ``servicename`` (string): Optional name by which clients can
307307
connect to the database instance. Will be used as Oracle's
308308
``SERVICE_NAME`` connection parameter if given.
309+
- ``sid`` (string): Optional identifier of the database instance to connect to.
309310
- ``pooled`` (boolean): Whether to enable database resident
310311
connection pooling.
311312
- ``charset`` (string): The charset used when connecting to the

src/Driver/AbstractOracleDriver/EasyConnectString.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Doctrine\DBAL\Driver\AbstractOracleDriver;
66

7+
use Doctrine\Deprecations\Deprecation;
8+
79
use function implode;
810
use function is_array;
911
use function sprintf;
@@ -53,12 +55,22 @@ public static function fromConnectionParameters(array $params): self
5355

5456
if (isset($params['dbname'])) {
5557
$connectData['SID'] = $params['dbname'];
58+
59+
Deprecation::trigger(
60+
'doctrine/dbal',
61+
'https://github.com/doctrine/dbal/pull/7239',
62+
'Using the "dbname" parameter is deprecated. Use "servicename" or "sid" instead.',
63+
);
5664
}
5765

5866
if (isset($params['servicename'])) {
5967
$connectData['SERVICE_NAME'] = $params['servicename'];
6068
}
6169

70+
if (isset($params['sid'])) {
71+
$connectData['SID'] = $params['sid'];
72+
}
73+
6274
if (isset($params['instancename'])) {
6375
$connectData['INSTANCE_NAME'] = $params['instancename'];
6476
}

src/DriverManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
* replica?: array<OverrideParams>,
6363
* serverVersion?: string,
6464
* sessionMode?: int,
65+
* sid?: string,
6566
* user?: non-empty-string,
6667
* wrapperClass?: class-string<Connection>,
6768
* unix_socket?: string,

tests/Driver/AbstractOracleDriver/EasyConnectStringTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
namespace Doctrine\DBAL\Tests\Driver\AbstractOracleDriver;
66

77
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
8+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
89
use PHPUnit\Framework\Attributes\DataProvider;
910
use PHPUnit\Framework\TestCase;
1011

1112
class EasyConnectStringTest extends TestCase
1213
{
14+
use VerifyDeprecations;
15+
1316
/** @param mixed[] $params */
1417
#[DataProvider('connectionParametersProvider')]
1518
public function testFromConnectionParameters(array $params, string $expected): void
@@ -70,4 +73,49 @@ public static function connectionParametersProvider(): iterable
7073
],
7174
];
7275
}
76+
77+
/** @param array<string, mixed> $parameters */
78+
#[DataProvider('getConnectionParameters')]
79+
public function testParameterDeprecation(
80+
array $parameters,
81+
string $expectedConnectString,
82+
bool $expectDeprecation,
83+
): void {
84+
if ($expectDeprecation) {
85+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7239');
86+
} else {
87+
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7239');
88+
}
89+
90+
$string = EasyConnectString::fromConnectionParameters($parameters);
91+
92+
self::assertSame($expectedConnectString, (string) $string);
93+
}
94+
95+
/** @return iterable<string, array{array<string, mixed>, string, bool}> */
96+
public static function getConnectionParameters(): iterable
97+
{
98+
$sidString = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))'
99+
. '(CONNECT_DATA=(SID=BILLING)))';
100+
101+
yield 'dbname' => [
102+
[
103+
'host' => 'localhost',
104+
'port' => 1521,
105+
'dbname' => 'BILLING',
106+
],
107+
$sidString,
108+
true,
109+
];
110+
111+
yield 'sid' => [
112+
[
113+
'host' => 'localhost',
114+
'port' => 1521,
115+
'sid' => 'BILLING',
116+
],
117+
$sidString,
118+
false,
119+
];
120+
}
73121
}

0 commit comments

Comments
 (0)