From b80bcaaba3f8422637d3de4204ae75eaf5ea1bbe Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 29 Jul 2015 13:51:42 -0700 Subject: [PATCH] Use STRAIGHT_JOIN in SpecialWhatlinkshere query * Also added a type hint to avoid IDE errors in this area Bug: T106682 Change-Id: I825eedaceb0c0323de85466e48582d72c57b201a --- includes/specials/SpecialWhatlinkshere.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 5db81d4f93..a6f92d659d 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -155,7 +155,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $conds['pagelinks'][] = 'rd_from is NOT NULL'; } - $queryFunc = function ( $dbr, $table, $fromCol ) use ( + $queryFunc = function ( IDatabase $dbr, $table, $fromCol ) use ( $conds, $target, $limit, $useLinkNamespaceDBFields ) { // Read an extra row as an at-end check @@ -170,11 +170,12 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { } // Inner LIMIT is 2X in case of stale backlinks with wrong namespaces $subQuery = $dbr->selectSqlText( - array( $table, 'page', 'redirect' ), + array( $table, 'redirect', 'page' ), array( $fromCol, 'rd_from' ), $conds[$table], __CLASS__ . '::showIndirectLinks', - array( 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit ), + // Force JOIN order per T106682 to avoid large filesorts + array( 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit, 'STRAIGHT_JOIN' ), array( 'page' => array( 'INNER JOIN', "$fromCol = page_id" ), 'redirect' => array( 'LEFT JOIN', $on ) -- 2.20.1