Skip to content

Commit

Permalink
Call compileQueries only when needed (NamelessMC#3386)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadhgboyle authored and Derkades committed Jun 13, 2023
1 parent 6f80651 commit fcd2ebc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions core/classes/Database/QueryRecorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ class QueryRecorder extends Instanceable {
* @return array SQL queries
*/
public function getSqlStack(): array {
return array_reverse($this->_query_stack);
$stack = array_reverse($this->_query_stack);

// Compile queries - replace bound parameters with their values and syntax highlight
foreach ($stack as &$query) {
$query['sql_query'] = $this->compileQuery(
$query['sql_string'],
$query['sql_params']
);
}

return $stack;
}

/**
Expand All @@ -38,7 +48,8 @@ public function pushQuery(string $sql, array $params): void {
$this->_query_stack[] = [
'number' => $this->_query_stack_num,
'frame' => ErrorHandler::parseFrame(null, $backtrace['file'], $backtrace['line'], $this->_query_stack_num),
'sql_query' => $this->compileQuery($sql, $params)
'sql_string' => $sql,
'sql_params' => $params,
];

$this->_query_stack_num++;
Expand Down

0 comments on commit fcd2ebc

Please sign in to comment.