Skip to content

Commit

Permalink
Fix SELECT queries with zero matching rows not being logged.
Browse files Browse the repository at this point in the history
Refs #14685, #14676
  • Loading branch information
ADmad committed Aug 5, 2020
1 parent a77d2d6 commit 386a133
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions Log/LoggingStatement.php
Expand Up @@ -81,8 +81,7 @@ public function execute(?array $params = null): bool
}

if (preg_match('/^(?!SELECT)/i', $this->queryString)) {
$this->loggedQuery->numRows = $this->rowCount();
$this->_log();
$this->rowCount();
}

return $result;
Expand All @@ -96,8 +95,7 @@ public function fetch($type = self::FETCH_TYPE_NUM)
$record = parent::fetch($type);

if ($this->loggedQuery) {
$this->loggedQuery->numRows = $this->rowCount();
$this->_log();
$this->rowCount();
}

return $record;
Expand All @@ -111,13 +109,27 @@ public function fetchAll($type = self::FETCH_TYPE_NUM)
$results = parent::fetchAll($type);

if ($this->loggedQuery) {
$this->loggedQuery->numRows = $this->rowCount();
$this->_log();
$this->rowCount();
}

return $results;
}

/**
* @inheritDoc
*/
public function rowCount(): int
{
$result = parent::rowCount();

if ($this->loggedQuery) {
$this->loggedQuery->numRows = $result;
$this->_log();
}

return $result;
}

/**
* Copies the logging data to the passed LoggedQuery and sends it
* to the logging system.
Expand Down

0 comments on commit 386a133

Please sign in to comment.