Add hook to allow extensions to modify the LonelyPages query
authorkaldari <rkaldari@wikimedia.org>
Wed, 8 Jan 2014 19:51:54 +0000 (11:51 -0800)
committerkaldari <rkaldari@wikimedia.org>
Wed, 8 Jan 2014 21:57:43 +0000 (13:57 -0800)
First step to solving bug 3483.

Bug: 3483
Change-Id: Ie8c5765ddc6b6028836024c426a0369e6966b25e

RELEASE-NOTES-1.23
docs/hooks.txt
includes/specials/SpecialLonelypages.php

index 8dd9923..8dfbb5f 100644 (file)
@@ -42,6 +42,8 @@ production.
 * (bug 56033) Add content model to the page information.
 * Added Article::MissingArticleConditions hook to give extensions a chance to
   hide their (unrelated) log entries.
+* Added LonelyPagesQuery hook to let extensions modify the query used to
+  generate Special:LonelyPages.
 * Added $wgOpenSearchDefaultLimit defining the default number of entries to show
   on action=opensearch API call.
 * For namespaces with $wgNamespaceProtection (including the MediaWiki
index ebc412b..bc09da7 100644 (file)
@@ -1595,6 +1595,12 @@ $paramArray: Array of parameters that corresponds to logging.log_params field.
 &$revert: string that is displayed in the UI, similar to $comment.
 $time: timestamp of the log entry (added in 1.12)
 
+'LonelyPagesQuery': Allow extensions to modify the query used by
+Special:LonelyPages.
+&$tables: tables to join in the query
+&$conds: conditions for the query
+&$joinConds: join conditions for the query
+
 'MaintenanceRefreshLinksInit': before executing the refreshLinks.php maintenance
 script.
 $refreshLinks: RefreshLinks object
index 7c7771d..f533234 100644 (file)
@@ -49,36 +49,40 @@ class LonelyPagesPage extends PageQueryPage {
        }
 
        function getQueryInfo() {
-               return array(
-                       'tables' => array(
-                               'page', 'pagelinks',
-                               'templatelinks'
+               $tables = array( 'page', 'pagelinks', 'templatelinks' );
+               $conds = array(
+                       'pl_namespace IS NULL',
+                       'page_namespace' => MWNamespace::getContentNamespaces(),
+                       'page_is_redirect' => 0,
+                       'tl_namespace IS NULL'
+               );
+               $joinConds = array(
+                       'pagelinks' => array(
+                               'LEFT JOIN', array(
+                                       'pl_namespace = page_namespace',
+                                       'pl_title = page_title'
+                               )
                        ),
+                       'templatelinks' => array(
+                               'LEFT JOIN', array(
+                                       'tl_namespace = page_namespace',
+                                       'tl_title = page_title'
+                               )
+                       )
+               );
+
+               // Allow extensions to modify the query
+               wfRunHooks( 'LonelyPagesQuery', array( &$tables, &$conds, &$joinConds ) );
+
+               return array(
+                       'tables' => $tables,
                        'fields' => array(
                                'namespace' => 'page_namespace',
                                'title' => 'page_title',
                                'value' => 'page_title'
                        ),
-                       'conds' => array(
-                               'pl_namespace IS NULL',
-                               'page_namespace' => MWNamespace::getContentNamespaces(),
-                               'page_is_redirect' => 0,
-                               'tl_namespace IS NULL'
-                       ),
-                       'join_conds' => array(
-                               'pagelinks' => array(
-                                       'LEFT JOIN', array(
-                                               'pl_namespace = page_namespace',
-                                               'pl_title = page_title'
-                                       )
-                               ),
-                               'templatelinks' => array(
-                                       'LEFT JOIN', array(
-                                               'tl_namespace = page_namespace',
-                                               'tl_title = page_title'
-                                       )
-                               )
-                       )
+                       'conds' => $conds,
+                       'join_conds' => $joinConds
                );
        }