Skip to content

Commit

Permalink
Remove AbstractPdoCommand::logQuery() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed May 10, 2024
1 parent 25de1a6 commit 3e05fff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 4 additions & 5 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -68,6 +66,7 @@ $db->createCommand()->insertBatch('user', $values)->execute();
- `AbstractDMLQueryBuilder::getTypecastValue()`
- `TableSchemaInterface::compositeForeignKey()`
- `Quoter::unquoteParts()`
- `AbstractPdoCommand::logQuery()`

### Remove deprecated parameters

Expand Down
20 changes: 3 additions & 17 deletions src/Driver/Pdo/AbstractPdoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3e05fff

Please sign in to comment.