From 580041be56b65dcd8cda98a1a6570cc2721935eb Mon Sep 17 00:00:00 2001 From: Agabi10 Date: Thu, 30 Aug 2018 13:35:44 +0000 Subject: [PATCH] Add a hook to allow changing the query of Special:AncientPages in extensions Bug: T76287 Change-Id: I6aa4d8e6140d405476a6f480156f24f2c05019cb --- docs/hooks.txt | 6 ++++++ includes/specials/SpecialAncientpages.php | 25 +++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 9cb22d23ed..436131cdd8 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -348,6 +348,12 @@ $from: From address $subject: Subject of the email $body: Body of the message +'AncientPagesQuery': Allow extensions to modify the query used by +Special:AncientPages. +&$tables: tables to join in the query +&$conds: conditions for the query +&$joinConds: join conditions for the query + 'APIAfterExecute': After calling the execute() method of an API module. Use this to extend core API modules. &$module: Module object diff --git a/includes/specials/SpecialAncientpages.php b/includes/specials/SpecialAncientpages.php index ff44bda1e9..088b060e61 100644 --- a/includes/specials/SpecialAncientpages.php +++ b/includes/specials/SpecialAncientpages.php @@ -43,18 +43,31 @@ class AncientPagesPage extends QueryPage { } public function getQueryInfo() { + $tables = [ 'page', 'revision' ]; + $conds = [ + 'page_namespace' => MWNamespace::getContentNamespaces(), + 'page_is_redirect' => 0 + ]; + $joinConds = [ + 'revision' => [ + 'INNER JOIN', [ + 'page_latest = rev_id' + ] + ], + ]; + + // Allow extensions to modify the query + Hooks::run( 'AncientPagesQuery', [ &$tables, &$conds, &$joinConds ] ); + return [ - 'tables' => [ 'page', 'revision' ], + 'tables' => $tables, 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'rev_timestamp' ], - 'conds' => [ - 'page_namespace' => MWNamespace::getContentNamespaces(), - 'page_is_redirect' => 0, - 'page_latest=rev_id' - ] + 'conds' => $conds, + 'join_conds' => $joinConds ]; } -- 2.20.1