Kaldari has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/283584

Change subject: Refactor code in DisambiguatorHooks to avoid redundancy
......................................................................

Refactor code in DisambiguatorHooks to avoid redundancy

Change-Id: I42f90ff3e8673e663a0d1e533f0a7fafd8f9692b
---
M Disambiguator.hooks.php
1 file changed, 19 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Disambiguator 
refs/changes/84/283584/1

diff --git a/Disambiguator.hooks.php b/Disambiguator.hooks.php
index 137cedb..60c3e79 100644
--- a/Disambiguator.hooks.php
+++ b/Disambiguator.hooks.php
@@ -29,6 +29,22 @@
        }
 
        /**
+        * Modify query parameters to ignore disambiguation pages
+        * @param array &$tables
+        * @param array &$conds
+        * @param array &$joinConds
+        * @return bool
+        */
+       private static function excludeDisambiguationPages( &$tables, &$conds, 
&$joinConds ) {
+               $tables[] = 'page_props';
+               $conds['pp_page'] = null;
+               $joinConds['page_props'] = array(
+                       'LEFT JOIN', array( 'page_id = pp_page', 'pp_propname' 
=> 'disambiguation' )
+               );
+               return true;
+       }
+
+       /**
         * Modify the Special:LonelyPages query to ignore disambiguation pages
         * @param array &$tables
         * @param array &$conds
@@ -36,12 +52,7 @@
         * @return bool
         */
        public static function onLonelyPagesQuery( &$tables, &$conds, 
&$joinConds ) {
-               $tables[] = 'page_props';
-               $conds['pp_page'] = null;
-               $joinConds['page_props'] = array(
-                       'LEFT JOIN', array( 'page_id = pp_page', 'pp_propname' 
=> 'disambiguation' )
-               );
-               return true;
+               return self::excludeDisambiguationPages( $tables, $conds, 
$joinConds );
        }
 
        /**
@@ -53,12 +64,7 @@
         * @return bool
         */
        public static function onShortPagesQuery( &$tables, &$conds, 
&$joinConds, &$options ) {
-               $tables[] = 'page_props';
-               $conds['pp_page'] = null;
-               $joinConds['page_props'] = array(
-                       'LEFT JOIN', array( 'page_id = pp_page', 'pp_propname' 
=> 'disambiguation' )
-               );
-               return true;
+               return self::excludeDisambiguationPages( $tables, $conds, 
$joinConds );
        }
 
        /**
@@ -69,12 +75,7 @@
         * @return bool
         */
        public static function onRandomPageQuery( &$tables, &$conds, 
&$joinConds ) {
-               $tables[] = 'page_props';
-               $conds['pp_page'] = null;
-               $joinConds['page_props'] = array(
-                       'LEFT JOIN', array( 'page_id = pp_page', 'pp_propname' 
=> 'disambiguation' )
-               );
-               return true;
+               return self::excludeDisambiguationPages( $tables, $conds, 
$joinConds );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/283584
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42f90ff3e8673e663a0d1e533f0a7fafd8f9692b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Disambiguator
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to