Skip to content

Commit

Permalink
Add fixes for DPL3
Browse files Browse the repository at this point in the history
  • Loading branch information
rvogel authored and it-spiderman committed May 30, 2022
1 parent dd6fcfc commit fac8358
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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;

0 comments on commit fac8358

Please sign in to comment.