From 0db94b498fa9b90f5f713b2dbbd341c72439e5a0 Mon Sep 17 00:00:00 2001 From: Kaldari Date: Tue, 5 Jan 2016 16:03:49 -0800 Subject: [PATCH] Add hook to allow extensions to modify query used by Special:ShortPages Also fix USE INDEX so that it won't break if another table is joined. See related change at I2a7003f9. Bug: T53124 Change-Id: I9ac910bc4c24196b1f19e2fc7f1e5b88a0dac41b --- docs/hooks.txt | 7 +++++++ includes/specials/SpecialShortpages.php | 21 +++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index fe88fa7d56..f2f04f3dec 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2568,6 +2568,13 @@ $enotif: EmailNotification object 'SetupAfterCache': Called in Setup.php, after cache objects are set +'ShortPagesQuery': Allow extensions to modify the query used by +Special:ShortPages. +&$tables: tables to join in the query +&$conds: conditions for the query +&$joinConds: join conditions for the query +&$options: options for the query + 'ShowMissingArticle': Called when generating the output for a non-existent page. $article: The article object corresponding to the page diff --git a/includes/specials/SpecialShortpages.php b/includes/specials/SpecialShortpages.php index ba11862e5e..74a1322ec8 100644 --- a/includes/specials/SpecialShortpages.php +++ b/includes/specials/SpecialShortpages.php @@ -38,18 +38,27 @@ class ShortPagesPage extends QueryPage { } public function getQueryInfo() { + $tables = array( 'page' ); + $conds = array( + 'page_namespace' => MWNamespace::getContentNamespaces(), + 'page_is_redirect' => 0 + ); + $joinConds = array(); + $options = array( 'USE INDEX' => array( 'page' => 'page_redirect_namespace_len' ) ); + + // Allow extensions to modify the query + Hooks::run( 'ShortPagesQuery', array( &$tables, &$conds, &$joinConds, &$options ) ); + return array( - 'tables' => array( 'page' ), + 'tables' => $tables, 'fields' => array( 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_len' ), - 'conds' => array( - 'page_namespace' => MWNamespace::getContentNamespaces(), - 'page_is_redirect' => 0 - ), - 'options' => array( 'USE INDEX' => 'page_redirect_namespace_len' ) + 'conds' => $conds, + 'join_conds' => $joinConds, + 'options' => $options ); } -- 2.20.1