Add hook to allow extensions to modify query used by Special:ShortPages
authorKaldari <rkaldari@wikimedia.org>
Wed, 6 Jan 2016 00:03:49 +0000 (16:03 -0800)
committerKaldari <rkaldari@wikimedia.org>
Wed, 6 Jan 2016 18:53:58 +0000 (10:53 -0800)
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
includes/specials/SpecialShortpages.php

index fe88fa7..f2f04f3 100644 (file)
@@ -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
 
index ba11862..74a1322 100644 (file)
@@ -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
                );
        }