Skip to content

Commit 265184e

Browse files
feature #50579 [DoctrineBridge] Deprecate using the old DBAL logger system (derrabus)
This PR was merged into the 6.4 branch. Discussion ---------- [DoctrineBridge] Deprecate using the old DBAL logger system | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | yes | Tickets | Backport from #50571 | License | MIT | Doc PR | N/A Commits ------- a8f6243 Deprecate using the old DBAL logger system
2 parents 09bfd4b + a8f6243 commit 265184e

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

UPGRADE-6.4.md

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

4+
DoctrineBridge
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
HttpFoundation
512
--------------
613

src/Symfony/Bridge/Doctrine/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

src/Symfony/Bridge/Doctrine/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

src/Symfony/Bridge/Doctrine/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 <fabien@symfony.com>
22+
*
23+
* @deprecated since Symfony 6.4, use a middleware instead.
2024
*/
2125
class DbalLogger implements SQLLogger
2226
{

src/Symfony/Bridge/Doctrine/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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy