diff --git a/includes/Parse.php b/includes/Parse.php index b6775a3..58b579f 100644 --- a/includes/Parse.php +++ b/includes/Parse.php @@ -202,7 +202,13 @@ class Parse { $query = new Query( $this->parameters ); $foundRows = null; - $rows = $query->buildAndSelect( $calcRows, $foundRows ); + $profilingContext = ''; + $currentTitle= $parser->getTitle(); + if ( $currentTitle instanceof Title ) { + $profilingContext + = str_replace( [ '*', '/' ], '-', $currentTitle->getPrefixedDBkey() ); + } + $rows = $query->buildAndSelect( $calcRows, $foundRows, $profilingContext ); if ( $rows === false ) { // This error path is very fast (We exit immediately if poolcounter is full) // Thus it should be safe to try again in ~5 minutes. diff --git a/includes/Query.php b/includes/Query.php index 879782c..24901d4 100644 --- a/includes/Query.php +++ b/includes/Query.php @@ -167,9 +167,10 @@ class Query { * * @param bool $calcRows * @param ?int &$foundRows + * @param string $profilingContext Used to see the origin of a query in the profiling * @return array|bool */ - public function buildAndSelect( bool $calcRows = false, ?int &$foundRows = null ) { + public function buildAndSelect( bool $calcRows = false, ?int &$foundRows = null, $profilingContext = '' ) { global $wgNonincludableNamespaces, $wgDebugDumpSql; $options = []; @@ -363,10 +364,10 @@ class Query { $options['MAX_EXECUTION_TIME'] = $maxQueryTime; } - $parser = MediaWikiServices::getInstance()->getParser(); - $pageName = str_replace( [ '*', '/' ], '-', $parser->getTitle()->getPrefixedDBkey() ); - - $qname = __METHOD__ . ' - ' . $pageName; + $qname = __METHOD__; + if ( !empty( $profilingContext ) ) { + $qname .= ' - ' . $profilingContext; + } $where = $this->where; $join = $this->join; $db = $this->dbr;