8000 [DoctrineBridge] Deprecate using the old DBAL logger system by derrabus · Pull Request #50579 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions UPGRADE-6.4.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
UPGRADE FROM 6.3 to 6.4
=======================

DoctrineBridge
--------------

* Deprecate `DbalLogger`, use a middleware instead
* Deprecate not constructing `DoctrineDataCollector` with an instance of `DebugDataHolder`
* Deprecate `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead

HttpFoundation
--------------

Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Bridge/Doctrine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

6.4
---

* Deprecate `DbalLogger`, use a middleware instead
* Deprecate not constructing `DoctrineDataCollector` with an instance of `DebugDataHolder`
* Deprecate `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead

6.3
---

Expand Down
8 changes: 8 additions & 0 deletions 10BC0 src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,23 @@ public function __construct(
) {
$this->connections = $registry->getConnectionNames();
$this->managers = $registry->getManagerNames();

if (null === $debugDataHolder) {
trigger_deprecation('symfony/doctrine-bridge', '6.4', 'Not passing an instance of "%s" as "$debugDataHolder" to "%s()" is deprecated.', DebugDataHolder::class, __METHOD__);
}
}

/**
* Adds the stack logger for a connection.
*
* @return void
*
* @deprecated since Symfony 6.4, use a DebugDataHolder instead.
*/
public function addLogger(string $name, DebugStack $logger)
{
trigger_deprecation('symfony/doctrine-bridge', '6.4', '"%s()" is deprecated. Pass an instance of "%s" to the constructor instead.', __METHOD__, DebugDataHolder::class);

$this->loggers[$name] = $logger;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\Stopwatch\Stopwatch;

trigger_deprecation('symfony/doctrine-bridge', '6.4', '"%s" is deprecated, use a middleware instead.', DbalLogger::class);

/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since Symfony 6.4, use a middleware instead.
*/
class DbalLogger implements SQLLogger
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\VarDumper\Cloner\Data;
Expand All @@ -31,6 +32,7 @@ class_exists(\Doctrine\DBAL\Platforms\MySqlPlatform::class);
class DoctrineDataCollectorWithDebugStackTest extends TestCase
{
use DoctrineDataCollectorTestTrait;
use ExpectDeprecationTrait;

public function testReset()
{
Expand Down Expand Up @@ -178,9 +180,12 @@ private function createCollector(array $queries): DoctrineDataCollector
->method('getConnection')
->willReturn($connection);

$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.');
$collector = new DoctrineDataCollector($registry);
$logger = $this->createMock(DebugStack::class);
$logger->queries = $queries;

$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.');
$collector->addLogger('default', $logger);

return $collector;
Expand Down
0