Add a hook to allow changing the query of Special:AncientPages in extensions
authorAgabi10 <gabilondo.ander@gmail.com>
Thu, 30 Aug 2018 13:35:44 +0000 (13:35 +0000)
committerAgabi10 <gabilondo.ander@gmail.com>
Fri, 31 Aug 2018 15:54:45 +0000 (15:54 +0000)
Bug: T76287
Change-Id: I6aa4d8e6140d405476a6f480156f24f2c05019cb

docs/hooks.txt
includes/specials/SpecialAncientpages.php

index 9cb22d2..436131c 100644 (file)
@@ -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
index ff44bda..088b060 100644 (file)
@@ -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
                ];
        }