Skip to content

Commit

Permalink
Deprecate Configuration::getSQLLogger() and setSQLLogger()
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jul 9, 2022
1 parent 2485d0a commit fc82cdc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ an exception. The characters are the following: `{}()/\@`.
The `SQLLogger` and its implementations `DebugStack` and `LoggerChain` have been deprecated.
For logging purposes, use `Doctrine\DBAL\Logging\Middleware` instead. No replacement for `DebugStack` is provided.

The `Configuration` methods `getSQLLogger()` and `setSQLLogger()` have been deprecated as well.

## Deprecated `SqliteSchemaManager::createDatabase()` and `dropDatabase()` methods.

The `SqliteSchemaManager::createDatabase()` and `dropDatabase()` methods have been deprecated. The SQLite engine
Expand Down
6 changes: 6 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@
See https://github.com/doctrine/dbal/pull/5136
-->
<referencedMethod name="Doctrine\DBAL\Types\Type::canRequireSQLConversion"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/4967
-->
<referencedMethod name="Doctrine\DBAL\Configuration::getSQLLogger"/>
<referencedMethod name="Doctrine\DBAL\Configuration::setSQLLogger"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down
18 changes: 18 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,35 @@ class Configuration

/**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
*
* @deprecated Use {@see setMiddlewares()} and {@see \Doctrine\DBAL\Logging\Middleware} instead.
*/
public function setSQLLogger(?SQLLogger $logger = null): void
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4967',
'%s is deprecated, use setMiddlewares() and Logging\\Middleware instead.',
__METHOD__
);

$this->sqlLogger = $logger;
}

/**
* Gets the SQL logger that is used.
*
* @deprecated
*/
public function getSQLLogger(): ?SQLLogger
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4967',
'%s is deprecated.',
__METHOD__
);

return $this->sqlLogger;
}

Expand Down

0 comments on commit fc82cdc

Please sign in to comment.