Skip to content

Commit 7527314

Browse files
committed
Deprecate using the old DBAL logger system
1 parent bc4c413 commit 7527314

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
6.4
5+
---
6+
7+
* Deprecate `DbalLogger`, use a middleware instead
8+
* Deprecate not constructing `DoctrineDataCollector` with an instance of `DebugDataHolder`
9+
* Deprecate `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead
10+
411
6.3
512
---
613

DataCollector/DoctrineDataCollector.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,23 @@ public function __construct(
4343
) {
4444
$this->connections = $registry->getConnectionNames();
4545
$this->managers = $registry->getManagerNames();
46+
47+
if (null === $debugDataHolder) {
48+
trigger_deprecation('symfony/doctrine-bridge', '6.4', 'Not passing an instance of "%s" as "$debugDataHolder" to "%s()" is deprecated.', DebugDataHolder::class, __METHOD__);
49+
}
4650
}
4751

4852
/**
4953
* Adds the stack logger for a connection.
5054
*
5155
* @return void
56+
*
57+
* @deprecated since Symfony 6.4, use a DebugDataHolder instead.
5258
*/
5359
public function addLogger(string $name, DebugStack $logger)
5460
{
61+
trigger_deprecation('symfony/doctrine-bridge', '6.4', '"%s()" is deprecated. Pass an instance of "%s" to the constructor instead.', __METHOD__, DebugDataHolder::class);
62+
5563
$this->loggers[$name] = $logger;
5664
}
5765

Logger/DbalLogger.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
use Psr\Log\LoggerInterface;
1616
use Symfony\Component\Stopwatch\Stopwatch;
1717

18+
trigger_deprecation('symfony/doctrine-bridge', '6.4', '"%s" is deprecated, use a middleware instead.', DbalLogger::class);
19+
1820
/**
1921
* @author Fabien Potencier <[email protected]>
22+
*
23+
* @deprecated since Symfony 6.4, use a middleware instead.
2024
*/
2125
class DbalLogger implements SQLLogger
2226
{

Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\Persistence\ManagerRegistry;
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
20+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
2021
use Symfony\Component\HttpFoundation\Request;
2122
use Symfony\Component\HttpFoundation\Response;
2223
use Symfony\Component\VarDumper\Cloner\Data;
@@ -31,6 +32,7 @@ class_exists(\Doctrine\DBAL\Platforms\MySqlPlatform::class);
3132
class DoctrineDataCollectorWithDebugStackTest extends TestCase
3233
{
3334
use DoctrineDataCollectorTestTrait;
35+
use ExpectDeprecationTrait;
3436

3537
public function testReset()
3638
{
@@ -178,9 +180,12 @@ private function createCollector(array $queries): DoctrineDataCollector
178180
->method('getConnection')
179181
->willReturn($connection);
180182

183+
$this->expectDeprecation('Since symfony/doctrine-bridge 6.4: Not passing an instance of "Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder" as "$debugDataHolder" to "Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector::__construct()" is deprecated.');
181184
$collector = new DoctrineDataCollector($registry);
182185
$logger = $this->createMock(DebugStack::class);
183186
$logger->queries = $queries;
187+
188+
$this->expectDeprecation('Since symfony/doctrine-bridge 6.4: "Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector::addLogger()" is deprecated. Pass an instance of "Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder" to the constructor instead.');
184189
$collector->addLogger('default', $logger);
185190

186191
return $collector;

0 commit comments

Comments
 (0)