WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 95b1840

Browse files
committed
Merge branch '4.5.x' into 5.0.x
2 parents 821610f + cfe0d15 commit 95b1840

File tree

9 files changed

+83
-8
lines changed

9 files changed

+83
-8
lines changed

UPGRADE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,15 @@ all drivers and middleware.
419419

420420
# Upgrade to 4.5
421421

422+
## Deprecated not specifying either of the `host` and `connectstring` parameters for `oci8` and `pdo_oci` connections.
423+
424+
Not specifying either of the `host` and `connectstring` parameters for `oci8` and `pdo_oci` connections has been
425+
deprecated. One of them must be specified.
426+
422427
## Deprecated `dbname` connection parameter for `oci8` and `pdo_oci` connections.
423428

424-
Using the `dbname` connection parameter for `oci8` and `pdo_oci` connections has been deprecated. Use `servicename` or
425-
`sid` instead.
429+
Using the `dbname` connection parameter for `oci8` and `pdo_oci` connections has been deprecated. Use `servicename`,
430+
`sid` or `connectstring` instead.
426431

427432
# Upgrade to 4.4
428433

docs/en/reference/configuration.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ pdo_oci / oci8
300300
database.
301301
- ``password`` (string): Password to use when connecting to the
302302
database.
303-
- ``host`` (string): Hostname of the database to connect to.
303+
- ``host`` (string): Hostname of the database to connect to. The hostname needs to be specified unless
304+
``connectstring`` is specified.
304305
- ``port`` (integer): Port of the database to connect to.
305306
- ``dbname`` (string): Name of the database/schema to connect to. Using this parameter is deprecated.
306307
- ``servicename`` (string): Optional name by which clients can
@@ -317,8 +318,7 @@ pdo_oci / oci8
317318
- ``connectstring`` (string): Complete Easy Connect connection descriptor,
318319
see `docs.oracle.com/en/database/oracle/oracle-database/23/netag/configuring-naming-methods.html <https://docs.oracle.com/en/database/oracle/oracle-database/23/netag/configuring-naming-methods.html>`_. When using this option,
319320
you will still need to provide the ``user`` and ``password`` parameters, but the other
320-
parameters will no longer be used. Note that when using this parameter, the ``getHost``
321-
and ``getPort`` methods from ``Doctrine\DBAL\Connection`` will no longer function as expected.
321+
parameters will no longer be used.
322322
- ``persistent`` (boolean): Whether to establish a persistent connection.
323323
- ``driverOptions`` (array):
324324
- ``exclusive`` (boolean): Once specified for an ``oci8`` connection, forces the driver to always establish

src/Connection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,11 @@ public function transactional(Closure $func): mixed
931931
$res = $func($this);
932932

933933
$successful = true;
934+
} catch (ConnectionLost $connectionLost) {
935+
// Catching here only to be able to prevent a rollback attempt
936+
throw $connectionLost;
934937
} finally {
935-
if (! $successful) {
938+
if (! isset($connectionLost) && ! $successful) {
936939
$this->rollBack();
937940
}
938941
}
@@ -948,6 +951,7 @@ public function transactional(Closure $func): mixed
948951
|| $t instanceof UniqueConstraintViolationException
949952
|| $t instanceof ForeignKeyConstraintViolationException
950953
|| $t instanceof DeadlockException
954+
|| $t instanceof ConnectionLost
951955
);
952956

953957
throw $t;

src/Driver/AbstractOracleDriver/EasyConnectString.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public static function fromConnectionParameters(array $params): self
4848
}
4949

5050
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+
5157
return new self($params['dbname'] ?? '');
5258
}
5359

@@ -59,7 +65,8 @@ public static function fromConnectionParameters(array $params): self
5965
Deprecation::trigger(
6066
'doctrine/dbal',
6167
'https://github.com/doctrine/dbal/pull/7239',
62-
'Using the "dbname" parameter is deprecated. Use "servicename" or "sid" instead.',
68+
'Using the "dbname" parameter is deprecated. Use "servicename", "sid" or "connectstring"'
69+
. ' instead.',
6370
);
6471
}
6572

src/Schema/Column.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* charset?: ?non-empty-string,
3636
* collation?: ?non-empty-string,
3737
* default_constraint_name?: non-empty-string,
38+
* enumType?: class-string,
3839
* }
3940
*/
4041
class Column extends AbstractNamedObject
@@ -262,6 +263,16 @@ public function getMaximumValue(): mixed
262263
return $this->_platformOptions['max'] ?? null;
263264
}
264265

266+
/**
267+
* Returns the enum type used by the column.
268+
*
269+
* @return ?class-string
270+
*/
271+
public function getEnumType(): ?string
272+
{
273+
return $this->_platformOptions['enumType'] ?? null;
274+
}
275+
265276
/**
266277
* @internal Should be used only from within the {@see AbstractSchemaManager} class hierarchy.
267278
*
@@ -366,6 +377,7 @@ public function edit(): ColumnEditor
366377
->setCollation($this->getCollation())
367378
->setMinimumValue($this->getMinimumValue())
368379
->setMaximumValue($this->getMaximumValue())
380+
->setEnumType($this->getEnumType())
369381
->setDefaultConstraintName($this->getDefaultConstraintName());
370382
}
371383
}

src/Schema/ColumnEditor.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ final class ColumnEditor
3434

3535
private mixed $maximumValue = null;
3636

37+
/** @var ?class-string */
38+
private ?string $enumType = null;
39+
3740
private bool $autoincrement = false;
3841

3942
private string $comment = '';
@@ -159,6 +162,14 @@ public function setMaximumValue(mixed $maximumValue): self
159162
return $this;
160163
}
161164

165+
/** @param ?class-string $enumType */
166+
public function setEnumType(?string $enumType): self
167+
{
168+
$this->enumType = $enumType;
169+
170+
return $this;
171+
}
172+
162173
public function setAutoincrement(bool $flag): self
163174
{
164175
$this->autoincrement = $flag;
@@ -245,6 +256,10 @@ public function create(): Column
245256
$platformOptions['max'] = $this->maximumValue;
246257
}
247258

259+
if ($this->enumType !== null) {
260+
$platformOptions['enumType'] = $this->enumType;
261+
}
262+
248263
if ($this->defaultConstraintName !== null) {
249264
$platformOptions[SQLServerPlatform::OPTION_DEFAULT_CONSTRAINT_NAME] = $this->defaultConstraintName;
250265
}

tests/Driver/AbstractOracleDriver/EasyConnectStringTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function testFromConnectionParameters(array $params, string $expected): v
2626
public static function connectionParametersProvider(): iterable
2727
{
2828
return [
29-
'empty-params' => [[],''],
3029
'common-params' => [
3130
[
3231
'host' => 'oracle.example.com',
@@ -118,4 +117,13 @@ public static function getConnectionParameters(): iterable
118117
false,
119118
];
120119
}
120+
121+
public function testNoHostOrConnectStringSpecified(): void
122+
{
123+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7244');
124+
125+
$string = EasyConnectString::fromConnectionParameters([]);
126+
127+
self::assertSame('', (string) $string);
128+
}
121129
}

tests/Functional/TransactionTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ public function testRollbackFailure(): void
4848
});
4949
}
5050

51+
public function testTransactionalFailureDuringCallback(): void
52+
{
53+
$this->connection->transactional(
54+
function (): void {
55+
$this->expectConnectionLoss(static function (Connection $connection): void {
56+
$connection->executeQuery($connection->getDatabasePlatform()->getDummySelectSQL());
57+
});
58+
},
59+
);
60+
}
61+
62+
public function testTransactionalFailureDuringCommit(): void
63+
{
64+
$this->connection->transactional(
65+
function (): void {
66+
$this->expectConnectionLoss(static function (Connection $connection): void {
67+
});
68+
},
69+
);
70+
}
71+
5172
private function expectConnectionLoss(callable $scenario): void
5273
{
5374
$this->killCurrentSession();

tests/Schema/ColumnTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function testGet(): void
3535
self::assertEquals('baz', $column->getDefault());
3636

3737
self::assertEquals('utf8', $column->getCharset());
38+
self::assertEquals(self::class, $column->getEnumType());
3839
self::assertNull($column->getCollation());
3940
}
4041

@@ -55,6 +56,7 @@ public function testToArray(): void
5556
'comment' => '',
5657
'values' => [],
5758
'charset' => 'utf8',
59+
'enumType' => self::class,
5860
];
5961

6062
self::assertEquals($expected, $this->createColumn()->toArray());
@@ -93,6 +95,7 @@ public function createColumn(): Column
9395
->setFixed(true)
9496
->setDefaultValue('baz')
9597
->setCharset('utf8')
98+
->setEnumType(self::class)
9699
->create();
97100
}
98101

0 commit comments

Comments
 (0)