Skip to content

Commit 63e0648

Browse files
authored
Merge pull request #7247 from morozov/remove-oracle-dbname
Remove support for "dbname" in oci8 and pdo_oci configuration
2 parents 95b1840 + dfba17d commit 63e0648

8 files changed

Lines changed: 41 additions & 79 deletions

File tree

UPGRADE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ awareness about deprecated code.
88

99
# Upgrade to 5.0
1010

11+
## BC BREAK: Either of the `host` and `connectstring` parameters must be specified for `oci8` and `pdo_oci` connections.
12+
13+
Not specifying either of the `host` and `connectstring` parameters for `oci8` and `pdo_oci` connections is no longer
14+
supported.
15+
1116
## BC BREAK: Removed support for the current date, time and timestamp SQL expressions as default values
1217

1318
Using SQL expressions for the current date, time, or timestamp as column default values is no longer supported. The
@@ -72,9 +77,9 @@ The `AbstractAsset` class has been removed.
7277

7378
The `AbstractAsset::isQuoted()` and `AbstractAsset::getName()` method has been removed.
7479

75-
## BC BREAK: Removed support for the `service` connection parameter.
80+
## BC BREAK: Removed support for the `dbname` and `service` connection parameters in `oci8` and `pdo_oci` configuration.
7681

77-
The `service` parameter of the `oci8` and `pdo_oci` connections is no longer supported.
82+
The `dbname` and `service` connection parameters are no longer supported in `oci8` and `pdo_oci` configuration.
7883

7984
## BC BREAK: Removed `Column` methods
8085

docs/en/reference/configuration.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ pdo_oci / oci8
303303
- ``host`` (string): Hostname of the database to connect to. The hostname needs to be specified unless
304304
``connectstring`` is specified.
305305
- ``port`` (integer): Port of the database to connect to.
306-
- ``dbname`` (string): Name of the database/schema to connect to. Using this parameter is deprecated.
307306
- ``servicename`` (string): Optional name by which clients can
308307
connect to the database instance. Will be used as Oracle's
309308
``SERVICE_NAME`` connection parameter if given.

src/Driver/AbstractOracleDriver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public function getExceptionConverter(): ExceptionConverterInterface
3030
* Returns an appropriate Easy Connect String for the given parameters.
3131
*
3232
* @param array<string, mixed> $params The connection parameters to return the Easy Connect String for.
33+
*
34+
* @throws Exception
3335
*/
3436
protected function getEasyConnectString(array $params): string
3537
{

src/Driver/AbstractOracleDriver/EasyConnectString.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace Doctrine\DBAL\Driver\AbstractOracleDriver;
66

7-
use Doctrine\Deprecations\Deprecation;
7+
use Doctrine\DBAL\Driver\AbstractOracleDriver\Exception\InvalidConfiguration;
8+
use Doctrine\DBAL\Driver\Exception;
89

910
use function implode;
1011
use function is_array;
@@ -40,6 +41,8 @@ public static function fromArray(array $params): self
4041
* Creates the object from the given DBAL connection parameters.
4142
*
4243
* @param mixed[] $params
44+
*
45+
* @throws Exception
4346
*/
4447
public static function fromConnectionParameters(array $params): self
4548
{
@@ -48,28 +51,11 @@ public static function fromConnectionParameters(array $params): self
4851
}
4952

5053
if (! isset($params['host'])) {
51-
Deprecation::trigger(
52-
'doctrine/dbal',
53-
'https://github.com/doctrine/dbal/pull/7244',
54-
'Not specifying either of the "host" and "connectstring" parameters is deprecated.',
55-
);
56-
57-
return new self($params['dbname'] ?? '');
54+
throw InvalidConfiguration::fromMissingHostAndConnectString();
5855
}
5956

6057
$connectData = [];
6158

62-
if (isset($params['dbname'])) {
63-
$connectData['SID'] = $params['dbname'];
64-
65-
Deprecation::trigger(
66-
'doctrine/dbal',
67-
'https://github.com/doctrine/dbal/pull/7239',
68-
'Using the "dbname" parameter is deprecated. Use "servicename", "sid" or "connectstring"'
69-
. ' instead.',
70-
);
71-
}
72-
7359
if (isset($params['servicename'])) {
7460
$connectData['SERVICE_NAME'] = $params['servicename'];
7561
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\DBAL\Driver\AbstractOracleDriver\Exception;
6+
7+
use Doctrine\DBAL\Driver\AbstractException;
8+
9+
/** @internal */
10+
final class InvalidConfiguration extends AbstractException
11+
{
12+
public static function fromMissingHostAndConnectString(): self
13+
{
14+
return new self('Neither of the "host" and "connectstring" parameters is specified.');
15+
}
16+
}

src/Driver/PDO/OCI/Driver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function connect(
5656
* Constructs the Oracle PDO DSN.
5757
*
5858
* @param mixed[] $params
59+
*
60+
* @throws \Doctrine\DBAL\Driver\Exception
5961
*/
6062
private function constructPdoDsn(array $params): string
6163
{

tests/Driver/AbstractOracleDriver/EasyConnectStringTest.php

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

77
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
8-
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
8+
use Doctrine\DBAL\Driver\AbstractOracleDriver\Exception\InvalidConfiguration;
99
use PHPUnit\Framework\Attributes\DataProvider;
1010
use PHPUnit\Framework\TestCase;
1111

1212
class EasyConnectStringTest extends TestCase
1313
{
14-
use VerifyDeprecations;
15-
1614
/** @param mixed[] $params */
1715
#[DataProvider('connectionParametersProvider')]
1816
public function testFromConnectionParameters(array $params, string $expected): void
@@ -26,15 +24,15 @@ public function testFromConnectionParameters(array $params, string $expected): v
2624
public static function connectionParametersProvider(): iterable
2725
{
2826
return [
29-
'common-params' => [
27+
'sid' => [
3028
[
3129
'host' => 'oracle.example.com',
3230
'port' => 1521,
33-
'dbname' => 'XE',
31+
'sid' => 'XE',
3432
],
3533
'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.example.com)(PORT=1521))(CONNECT_DATA=(SID=XE)))',
3634
],
37-
'no-db-name' => [
35+
'no-service-name-or-sid' => [
3836
['host' => 'localhost'],
3937
'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))',
4038
],
@@ -51,7 +49,7 @@ public static function connectionParametersProvider(): iterable
5149
[
5250
'host' => 'localhost',
5351
'port' => 41521,
54-
'dbname' => 'XE',
52+
'sid' => 'XE',
5553
'instancename' => 'SALES',
5654
'pooled' => true,
5755
],
@@ -62,7 +60,7 @@ public static function connectionParametersProvider(): iterable
6260
[
6361
'host' => 'localhost',
6462
'port' => 41521,
65-
'dbname' => 'XE',
63+
'sid' => 'XE',
6664
'instancename' => 'SALES',
6765
'pooled' => true,
6866
'driverOptions' => ['protocol' => 'TCPS'],
@@ -73,57 +71,10 @@ public static function connectionParametersProvider(): iterable
7371
];
7472
}
7573

76-
/** @param array<string, mixed> $parameters */
77-
#[DataProvider('getConnectionParameters')]
78-
public function testParameterDeprecation(
79-
array $parameters,
80-
string $expectedConnectString,
81-
bool $expectDeprecation,
82-
): void {
83-
if ($expectDeprecation) {
84-
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7239');
85-
} else {
86-
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7239');
87-
}
88-
89-
$string = EasyConnectString::fromConnectionParameters($parameters);
90-
91-
self::assertSame($expectedConnectString, (string) $string);
92-
}
93-
94-
/** @return iterable<string, array{array<string, mixed>, string, bool}> */
95-
public static function getConnectionParameters(): iterable
96-
{
97-
$sidString = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))'
98-
. '(CONNECT_DATA=(SID=BILLING)))';
99-
100-
yield 'dbname' => [
101-
[
102-
'host' => 'localhost',
103-
'port' => 1521,
104-
'dbname' => 'BILLING',
105-
],
106-
$sidString,
107-
true,
108-
];
109-
110-
yield 'sid' => [
111-
[
112-
'host' => 'localhost',
113-
'port' => 1521,
114-
'sid' => 'BILLING',
115-
],
116-
$sidString,
117-
false,
118-
];
119-
}
120-
12174
public function testNoHostOrConnectStringSpecified(): void
12275
{
123-
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7244');
124-
125-
$string = EasyConnectString::fromConnectionParameters([]);
76+
$this->expectException(InvalidConfiguration::class);
12677

127-
self::assertSame('', (string) $string);
78+
EasyConnectString::fromConnectionParameters([]);
12879
}
12980
}

tests/Driver/OCI8/DriverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function testPersistentAndExclusiveAreMutuallyExclusive(): void
1818
$this->expectException(InvalidConfiguration::class);
1919

2020
(new Driver())->connect([
21+
'host' => 'localhost',
2122
'persistent' => true,
2223
'driverOptions' => ['exclusive' => true],
2324
]);

0 commit comments

Comments
 (0)