Page MenuHomePhabricator
Authored By
Lucas_Werkmeister_WMDE
Feb 1 2022, 7:57 PM
Size
1 KB
Referenced Files
None
Subscribers
None

T297754-2.patch

From 3ded0bb7d2707d80bad703431c422e21ae57507c Mon Sep 17 00:00:00 2001
From: Lucas Werkmeister <lucas.werkmeister@wikimedia.de>
Date: Tue, 1 Feb 2022 20:55:16 +0100
Subject: [PATCH] SECURITY: Always filter by namespaces in WhatLinksHere
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This allows MySQL to use the backlinks indexes, which we want it to do
because we’re now sorting by the from_namespace and from (page ID).
Bug: T297754
Change-Id: I2cde031edcb52c927682b34f7b2f78d6d42aac82
---
includes/specials/SpecialWhatLinksHere.php | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/includes/specials/SpecialWhatLinksHere.php b/includes/specials/SpecialWhatLinksHere.php
index 04a60fa71a..0c6c19f26b 100644
--- a/includes/specials/SpecialWhatLinksHere.php
+++ b/includes/specials/SpecialWhatLinksHere.php
@@ -240,11 +240,15 @@ private function showIndirectLinks( $level, $target, $limit, $offsetNamespace =
} else {
$namespaces = $namespace;
}
- $conds['redirect']['page_namespace'] = $namespaces;
- $conds['pagelinks']['pl_from_namespace'] = $namespaces;
- $conds['templatelinks']['tl_from_namespace'] = $namespaces;
- $conds['imagelinks']['il_from_namespace'] = $namespaces;
- }
+ } else {
+ // Select all namespaces.
+ // This allows the database to use the *_from_namespace index. (T297754)
+ $namespaces = $this->namespaceInfo->getValidNamespaces();
+ }
+ $conds['redirect']['page_namespace'] = $namespaces;
+ $conds['pagelinks']['pl_from_namespace'] = $namespaces;
+ $conds['templatelinks']['tl_from_namespace'] = $namespaces;
+ $conds['imagelinks']['il_from_namespace'] = $namespaces;
if ( $offsetPageID ) {
$rel = $dir === 'prev' ? '<' : '>';
--
2.32.0

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9339233
Default Alt Text
T297754-2.patch (1 KB)

Event Timeline