Skip to content

Commit

Permalink
Only set sqlQuery if used for debug (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Mar 20, 2022
1 parent d5b3539 commit 181a322
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions includes/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ public function parse( $input, Parser $parser, &$reset, &$eliminate, $isParserTa
$numRows = count( $rows );
$articles = $this->processQueryResults( $rows, $parser );

global $wgDebugDumpSql;
if ( Hooks::getDebugLevel() >= 4 && $wgDebugDumpSql ) {
if ( $query->getSqlQuery() ) {
$this->addOutput( $query->getSqlQuery() . "\n" );
}

Expand Down
6 changes: 4 additions & 2 deletions includes/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function __construct( Parameters $parameters ) {
* @return array|bool
*/
public function buildAndSelect( bool $calcRows = false ) {
global $wgNonincludableNamespaces;
global $wgNonincludableNamespaces, $wgDebugDumpSql;

$options = [];

Expand Down Expand Up @@ -354,7 +354,9 @@ public function buildAndSelect( bool $calcRows = false ) {
);
}

$this->sqlQuery = $query;
if ( Hooks::getDebugLevel() >= 4 && $wgDebugDumpSql ) {
$this->sqlQuery = $query;
}

if ( $calcRows ) {
$calcRowsResult = $this->dbr->query( 'SELECT FOUND_ROWS() AS rowcount', __METHOD__ );
Expand Down

0 comments on commit 181a322

Please sign in to comment.