Skip to content

Commit 20dceb2

Browse files
Merge branch '5.4' into 6.2
* 5.4: Avoid call on null [Notifier] Document Firebase options object in readme [ErrorHandler] Fix sending Vary header with SerializerErrorRenderer Fix intl data tests [DoctrineBridge] fix issue with missing stopwatch events [HttpClient] Fix canceling MockResponse
2 parents 70e9e36 + 32cddf4 commit 20dceb2

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Middleware/Debug/Connection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function prepare(string $sql): DriverStatement
4242
$this->debugDataHolder,
4343
$this->connectionName,
4444
$sql,
45+
$this->stopwatch,
4546
);
4647
}
4748

Middleware/Debug/Statement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\DBAL\Driver\Result as ResultInterface;
1616
use Doctrine\DBAL\Driver\Statement as StatementInterface;
1717
use Doctrine\DBAL\ParameterType;
18+
use Symfony\Component\Stopwatch\Stopwatch;
1819

1920
/**
2021
* @author Laurent VOULLEMIER <[email protected]>
@@ -30,6 +31,7 @@ public function __construct(
3031
private DebugDataHolder $debugDataHolder,
3132
private string $connectionName,
3233
string $sql,
34+
private ?Stopwatch $stopwatch = null,
3335
) {
3436
parent::__construct($statement);
3537

@@ -59,12 +61,14 @@ public function execute($params = null): ResultInterface
5961
// clone to prevent variables by reference to change
6062
$this->debugDataHolder->addQuery($this->connectionName, $query = clone $this->query);
6163

64+
$this->stopwatch?->start('doctrine', 'doctrine');
6265
$query->start();
6366

6467
try {
6568
$result = parent::execute($params);
6669
} finally {
6770
$query->stop();
71+
$this->stopwatch?->stop('doctrine');
6872
}
6973

7074
return $result;

Tests/Middleware/Debug/MiddlewareTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ public function testWithParamBound(callable $executeMethod)
156156
$executeMethod($stmt);
157157

158158
// Debug data should not be affected by these changes
159-
$product = 'product2';
160-
$price = 13.5;
161-
$stock = 4;
162-
163159
$debug = $this->debugDataHolder->getData()['default'] ?? [];
164160
$this->assertCount(2, $debug);
165161
$this->assertSame('INSERT INTO products(name, price, stock) VALUES (?, ?, ?)', $debug[1]['sql']);
@@ -219,6 +215,14 @@ public static function provideExecuteAndEndTransactionMethods(): array
219215
static fn (Connection $conn, string $sql) => $conn->executeQuery($sql),
220216
static fn (Connection $conn) => $conn->rollBack(),
221217
],
218+
'prepared statement' => [
219+
static function (Connection $conn, string $sql): Result {
220+
return $conn->prepare($sql)->executeQuery();
221+
},
222+
static function (Connection $conn): bool {
223+
return $conn->commit();
224+
},
225+
],
222226
];
223227
}
224228

0 commit comments

Comments
 (0)