Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50c0fbc

Browse files
committed
Fix DBAL 4 compatibility
1 parent53e5e19 commit50c0fbc

File tree

19 files changed

+466
-197
lines changed

19 files changed

+466
-197
lines changed

‎src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function guessType(string $class, string $property)
5252
}
5353

5454
switch ($metadata->getTypeOfField($property)) {
55-
caseTypes::ARRAY:
55+
case'array':// DBAL < 4
5656
case Types::SIMPLE_ARRAY:
5757
returnnewTypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', [], Guess::MEDIUM_CONFIDENCE);
5858
case Types::BOOLEAN:

‎src/Symfony/Bridge/Doctrine/Messenger/DoctrinePingConnectionMiddleware.php‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespaceSymfony\Bridge\Doctrine\Messenger;
1313

14+
useDoctrine\DBAL\Connection;
1415
useDoctrine\DBAL\ExceptionasDBALException;
1516
useDoctrine\ORM\EntityManagerInterface;
1617
useSymfony\Component\Messenger\Envelope;
@@ -33,19 +34,28 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel
3334
return$stack->next()->handle($envelope,$stack);
3435
}
3536

36-
privatefunctionpingConnection(EntityManagerInterface$entityManager)
37+
privatefunctionpingConnection(EntityManagerInterface$entityManager):void
3738
{
3839
$connection =$entityManager->getConnection();
3940

4041
try {
41-
$connection->executeQuery($connection->getDatabasePlatform()->getDummySelectSQL());
42+
$this->executeDummySql($connection);
4243
}catch (DBALException$e) {
4344
$connection->close();
44-
$connection->connect();
45+
// Attempt to reestablish the lazy connection by sending another query.
46+
$this->executeDummySql($connection);
4547
}
4648

4749
if (!$entityManager->isOpen()) {
4850
$this->managerRegistry->resetManager($this->entityManagerName);
4951
}
5052
}
53+
54+
/**
55+
* @throws DBALException
56+
*/
57+
privatefunctionexecuteDummySql(Connection$connection):void
58+
{
59+
$connection->executeQuery($connection->getDatabasePlatform()->getDummySelectSQL());
60+
}
5161
}

‎src/Symfony/Bridge/Doctrine/Middleware/Debug/Connection.php‎

Lines changed: 37 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,26 @@
1414
useDoctrine\DBAL\Driver\ConnectionasConnectionInterface;
1515
useDoctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware;
1616
useDoctrine\DBAL\Driver\Result;
17-
useDoctrine\DBAL\Driver\StatementasDriverStatement;
1817
useSymfony\Component\Stopwatch\Stopwatch;
1918

2019
/**
2120
* @author Laurent VOULLEMIER <laurent.voullemier@gmail.com>
21+
* @author Alexander M. Turek <me@derrabus.de>
2222
*
2323
* @internal
2424
*/
2525
finalclass Connectionextends AbstractConnectionMiddleware
2626
{
27-
private$nestingLevel =0;
28-
private$debugDataHolder;
29-
private$stopwatch;
30-
private$connectionName;
31-
32-
publicfunction__construct(ConnectionInterface$connection,DebugDataHolder$debugDataHolder, ?Stopwatch$stopwatch,string$connectionName)
33-
{
27+
publicfunction__construct(
28+
ConnectionInterface$connection,
29+
privateDebugDataHolder$debugDataHolder,
30+
private ?Stopwatch$stopwatch,
31+
privatestring$connectionName,
32+
) {
3433
parent::__construct($connection);
35-
36-
$this->debugDataHolder =$debugDataHolder;
37-
$this->stopwatch =$stopwatch;
38-
$this->connectionName =$connectionName;
3934
}
4035

41-
publicfunctionprepare(string$sql):DriverStatement
36+
publicfunctionprepare(string$sql):Statement
4237
{
4338
returnnewStatement(
4439
parent::prepare($sql),
@@ -53,135 +48,79 @@ public function query(string $sql): Result
5348
{
5449
$this->debugDataHolder->addQuery($this->connectionName,$query =newQuery($sql));
5550

56-
if (null !==$this->stopwatch) {
57-
$this->stopwatch->start('doctrine','doctrine');
58-
}
59-
51+
$this->stopwatch?->start('doctrine','doctrine');
6052
$query->start();
6153

6254
try {
63-
$result =parent::query($sql);
55+
returnparent::query($sql);
6456
}finally {
6557
$query->stop();
66-
67-
if (null !==$this->stopwatch) {
68-
$this->stopwatch->stop('doctrine');
69-
}
58+
$this->stopwatch?->stop('doctrine');
7059
}
71-
72-
return$result;
7360
}
7461

7562
publicfunctionexec(string$sql):int
7663
{
7764
$this->debugDataHolder->addQuery($this->connectionName,$query =newQuery($sql));
7865

79-
if (null !==$this->stopwatch) {
80-
$this->stopwatch->start('doctrine','doctrine');
81-
}
82-
66+
$this->stopwatch?->start('doctrine','doctrine');
8367
$query->start();
8468

8569
try {
8670
$affectedRows =parent::exec($sql);
8771
}finally {
8872
$query->stop();
89-
90-
if (null !==$this->stopwatch) {
91-
$this->stopwatch->stop('doctrine');
92-
}
73+
$this->stopwatch?->stop('doctrine');
9374
}
9475

9576
return$affectedRows;
9677
}
9778

98-
publicfunctionbeginTransaction():bool
79+
publicfunctionbeginTransaction():void
9980
{
100-
$query =null;
101-
if (1 === ++$this->nestingLevel) {
102-
$this->debugDataHolder->addQuery($this->connectionName,$query =newQuery('"START TRANSACTION"'));
103-
}
104-
105-
if (null !==$this->stopwatch) {
106-
$this->stopwatch->start('doctrine','doctrine');
107-
}
81+
$query =newQuery('"START TRANSACTION"');
82+
$this->debugDataHolder->addQuery($this->connectionName,$query);
10883

109-
if (null !==$query) {
110-
$query->start();
111-
}
84+
$this->stopwatch?->start('doctrine','doctrine');
85+
$query->start();
11286

11387
try {
114-
$ret =parent::beginTransaction();
88+
parent::beginTransaction();
11589
}finally {
116-
if (null !==$query) {
117-
$query->stop();
118-
}
119-
120-
if (null !==$this->stopwatch) {
121-
$this->stopwatch->stop('doctrine');
122-
}
90+
$query->stop();
91+
$this->stopwatch?->stop('doctrine');
12392
}
124-
125-
return$ret;
12693
}
12794

128-
publicfunctioncommit():bool
95+
publicfunctioncommit():void
12996
{
130-
$query =null;
131-
if (1 ===$this->nestingLevel--) {
132-
$this->debugDataHolder->addQuery($this->connectionName,$query =newQuery('"COMMIT"'));
133-
}
97+
$query =newQuery('"COMMIT"');
98+
$this->debugDataHolder->addQuery($this->connectionName,$query);
13499

135-
if (null !==$this->stopwatch) {
136-
$this->stopwatch->start('doctrine','doctrine');
137-
}
138-
139-
if (null !==$query) {
140-
$query->start();
141-
}
100+
$this->stopwatch?->start('doctrine','doctrine');
101+
$query->start();
142102

143103
try {
144-
$ret =parent::commit();
104+
parent::commit();
145105
}finally {
146-
if (null !==$query) {
147-
$query->stop();
148-
}
149-
150-
if (null !==$this->stopwatch) {
151-
$this->stopwatch->stop('doctrine');
152-
}
106+
$query->stop();
107+
$this->stopwatch?->stop('doctrine');
153108
}
154-
155-
return$ret;
156109
}
157110

158-
publicfunctionrollBack():bool
111+
publicfunctionrollBack():void
159112
{
160-
$query =null;
161-
if (1 ===$this->nestingLevel--) {
162-
$this->debugDataHolder->addQuery($this->connectionName,$query =newQuery('"ROLLBACK"'));
163-
}
164-
165-
if (null !==$this->stopwatch) {
166-
$this->stopwatch->start('doctrine','doctrine');
167-
}
113+
$query =newQuery('"ROLLBACK"');
114+
$this->debugDataHolder->addQuery($this->connectionName,$query);
168115

169-
if (null !==$query) {
170-
$query->start();
171-
}
116+
$this->stopwatch?->start('doctrine','doctrine');
117+
$query->start();
172118

173119
try {
174-
$ret =parent::rollBack();
120+
parent::rollBack();
175121
}finally {
176-
if (null !==$query) {
177-
$query->stop();
178-
}
179-
180-
if (null !==$this->stopwatch) {
181-
$this->stopwatch->stop('doctrine');
182-
}
122+
$query->stop();
123+
$this->stopwatch?->stop('doctrine');
183124
}
184-
185-
return$ret;
186125
}
187126
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp