diff --git a/CHANGELOG.md b/CHANGELOG.md index 9548beb53..91186d070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Chg #841: Remove `$rawSql` parameter from `AbstractCommand::internalExecute()` method and `AbstractPdoCommand::internalExecute()` method (@Tigrov) - Enh #842: Allow `ExpressionInterface` for `$alias` parameter of `QueryPartsInterface::withQuery()` method (@Tigrov) +- Enh #843: Remove `AbstractPdoCommand::logQuery()` method (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/UPGRADE.md b/UPGRADE.md index c094144fe..ca227c8e7 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,11 +1,9 @@ # Yii Database Upgrading Instructions -> **!!!IMPORTANT!!!** +> **IMPORTANT** > -> The following upgrading instructions are *cumulative*. That is, -> if you want to upgrade from version A to version C and there is -> version B between A and C, you need to following the instructions -> for both A and B. +> The following upgrading instructions are *cumulative*. That is, if you want to upgrade from version A to version C +> and there is version B between A and C, you need to following the instructions for both A and B. ## Upgrade from 1.x to 2.x @@ -68,6 +66,7 @@ $db->createCommand()->insertBatch('user', $values)->execute(); - `AbstractDMLQueryBuilder::getTypecastValue()` - `TableSchemaInterface::compositeForeignKey()` - `Quoter::unquoteParts()` +- `AbstractPdoCommand::logQuery()` ### Remove deprecated parameters diff --git a/src/Driver/Pdo/AbstractPdoCommand.php b/src/Driver/Pdo/AbstractPdoCommand.php index eab69ea87..7a31bba2c 100644 --- a/src/Driver/Pdo/AbstractPdoCommand.php +++ b/src/Driver/Pdo/AbstractPdoCommand.php @@ -252,31 +252,17 @@ protected function internalGetQueryResult(int $queryMode): mixed return $result; } - /** - * Logs the current database query if query logging is on and returns the profiling token if profiling is on. - */ - protected function logQuery(string $rawSql, string $category): void - { - $this->logger?->log(LogLevel::INFO, $rawSql, [$category, 'type' => LogType::QUERY]); - } - protected function queryInternal(int $queryMode): mixed { $logCategory = self::class . '::' . $this->getQueryMode($queryMode); - if ($this->logger !== null) { - $rawSql = $this->getRawSql(); - $this->logQuery($rawSql, $logCategory); - } + $this->logger?->log(LogLevel::INFO, $rawSql = $this->getRawSql(), [$logCategory, 'type' => LogType::QUERY]); $queryContext = new CommandContext(__METHOD__, $logCategory, $this->getSql(), $this->getParams()); - /** - * @psalm-var string $rawSql - * @psalm-suppress RedundantConditionGivenDocblockType - * @psalm-suppress DocblockTypeContradiction - */ + /** @psalm-var string|null $rawSql */ $this->profiler?->begin($rawSql ??= $this->getRawSql(), $queryContext); + /** @psalm-var string $rawSql */ try { /** @psalm-var mixed $result */ $result = parent::queryInternal($queryMode);