Remove "include redirects" option from search
authorChad Horohoe <chadh@wikimedia.org>
Thu, 13 Mar 2014 20:39:47 +0000 (13:39 -0700)
committerChad Horohoe <chadh@wikimedia.org>
Wed, 26 Mar 2014 16:28:26 +0000 (09:28 -0700)
Always include redirects. Search results are worse without them
and MWSearch has never respected this option anyway.

Change-Id: I0ebe321a3b14e7960aa98e3225dc5a19ba916e7d

RELEASE-NOTES-1.23
includes/api/ApiQuerySearch.php
includes/search/SearchEngine.php
includes/search/SearchMssql.php
includes/search/SearchMySQL.php
includes/search/SearchOracle.php
includes/search/SearchPostgres.php
includes/search/SearchSqlite.php
includes/specials/SpecialSearch.php

index 340aa50..c1a3ce0 100644 (file)
@@ -222,6 +222,8 @@ production.
 * (bug 42026) Added ucshow={new,!new,top,!top} to list=usercontribs.
   Also added newonly to action=feedcontributions.
 * (bug 42026) Deprecated uctoponly in favor of ucshow=top.
+* list=search no longer has a "srredirects" parameter. Redirects are now
+  included in all searches.
 
 === Languages updated in 1.23 ===
 
@@ -303,6 +305,8 @@ changes to languages because of Bugzilla reports.
   us to extend parser tests to accommodate additional input/output
   pairs, such as "!!html/parsoid" (for the output of the Parsoid
   parser, where it differs from the PHP parser).
+* Special:Search no longer has an "include redirects" option on the advanced
+  tab. Redirects are now included in all searches.
 
 ==== Removed classes ====
 * FakeMemCachedClient (deprecated in 1.18)
index fcaaf10..a2a15e0 100644 (file)
@@ -72,7 +72,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                        SearchEngine::create( $params['backend'] ) : SearchEngine::create();
                $search->setLimitOffset( $limit + 1, $params['offset'] );
                $search->setNamespaces( $params['namespace'] );
-               $search->showRedirects = $params['redirects'];
 
                $query = $search->transformSearchTerm( $query );
                $query = $search->replacePrefixes( $query );
@@ -299,7 +298,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                ),
                                ApiBase::PARAM_ISMULTI => true,
                        ),
-                       'redirects' => false,
                        'offset' => 0,
                        'limit' => array(
                                ApiBase::PARAM_DFLT => 10,
@@ -345,7 +343,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                ' sectiontitle     - Adds the title of the matching section',
                                ' hasrelated       - Indicates whether a related search is available',
                        ),
-                       'redirects' => 'Include redirect pages in the search',
                        'offset' => 'Use this value to continue paging (return by query)',
                        'limit' => 'How many total pages to return',
                        'interwiki' => 'Include interwiki results in the search, if available'
index a96ade0..507a520 100644 (file)
@@ -35,7 +35,6 @@ class SearchEngine {
        var $prefix = '';
        var $searchTerms = array();
        var $namespaces = array( NS_MAIN );
-       var $showRedirects = false;
        protected $showSuggestion = true;
 
        /// Feature values
@@ -72,7 +71,6 @@ class SearchEngine {
         */
        public function supports( $feature ) {
                switch ( $feature ) {
-               case 'list-redirects':
                case 'search-update':
                        return true;
                case 'title-suffix-filter':
index 15b5f1c..d92c9c8 100644 (file)
@@ -50,20 +50,6 @@ class SearchMssql extends SearchDatabase {
                return new MssqlSearchResultSet( $resultSet, $this->searchTerms );
        }
 
-       /**
-        * Return a partial WHERE clause to exclude redirects, if so set
-        *
-        * @return String
-        * @private
-        */
-       function queryRedirect() {
-               if ( $this->showRedirects ) {
-                       return '';
-               } else {
-                       return 'AND page_is_redirect=0';
-               }
-       }
-
        /**
         * Return a partial WHERE clause to limit the search to the given namespaces
         *
@@ -109,7 +95,6 @@ class SearchMssql extends SearchDatabase {
         */
        function getQuery( $filteredTerm, $fulltext ) {
                return $this->queryLimit( $this->queryMain( $filteredTerm, $fulltext ) . ' ' .
-                       $this->queryRedirect() . ' ' .
                        $this->queryNamespaces() . ' ' .
                        $this->queryRanking( $filteredTerm, $fulltext ) . ' ' );
        }
index c3edf51..c4d7d1e 100644 (file)
@@ -218,9 +218,7 @@ class SearchMySQL extends SearchDatabase {
         */
        protected function queryFeatures( &$query ) {
                foreach ( $this->features as $feature => $value ) {
-                       if ( $feature === 'list-redirects' && !$value ) {
-                               $query['conds']['page_is_redirect'] = 0;
-                       } elseif ( $feature === 'title-suffix-filter' && $value ) {
+                       if ( $feature === 'title-suffix-filter' && $value ) {
                                $query['conds'][] = 'page_title' . $this->db->buildLike( $this->db->anyString(), $value );
                        }
                }
index 2603161..e14de2c 100644 (file)
@@ -89,18 +89,6 @@ class SearchOracle extends SearchDatabase {
                return new MySQLSearchResultSet( $resultSet, $this->searchTerms );
        }
 
-       /**
-        * Return a partial WHERE clause to exclude redirects, if so set
-        * @return String
-        */
-       function queryRedirect() {
-               if ( $this->showRedirects ) {
-                       return '';
-               } else {
-                       return 'AND page_is_redirect=0';
-               }
-       }
-
        /**
         * Return a partial WHERE clause to limit the search to the given namespaces
         * @return String
@@ -147,7 +135,6 @@ class SearchOracle extends SearchDatabase {
         */
        function getQuery( $filteredTerm, $fulltext ) {
                return $this->queryLimit( $this->queryMain( $filteredTerm, $fulltext ) . ' ' .
-                       $this->queryRedirect() . ' ' .
                        $this->queryNamespaces() . ' ' .
                        $this->queryRanking( $filteredTerm, $fulltext ) . ' ' );
        }
index 142e5fd..4da63b3 100644 (file)
@@ -168,11 +168,6 @@ class SearchPostgres extends SearchDatabase {
                        "AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery($searchstring)";
                }
 
-               ## Redirects
-               if ( !$this->showRedirects ) {
-                       $query .= ' AND page_is_redirect = 0';
-               }
-
                ## Namespaces - defaults to 0
                if ( !is_null( $this->namespaces ) ) { // null -> search all
                        if ( count( $this->namespaces ) < 1 ) {
index ebff68e..6b2b3c6 100644 (file)
@@ -184,18 +184,6 @@ class SearchSqlite extends SearchDatabase {
                return new SqliteSearchResultSet( $resultSet, $this->searchTerms, $total );
        }
 
-       /**
-        * Return a partial WHERE clause to exclude redirects, if so set
-        * @return String
-        */
-       function queryRedirect() {
-               if ( $this->showRedirects ) {
-                       return '';
-               } else {
-                       return 'AND page_is_redirect=0';
-               }
-       }
-
        /**
         * Return a partial WHERE clause to limit the search to the given namespaces
         * @return String
@@ -231,7 +219,6 @@ class SearchSqlite extends SearchDatabase {
        function getQuery( $filteredTerm, $fulltext ) {
                return $this->limitResult(
                        $this->queryMain( $filteredTerm, $fulltext ) . ' ' .
-                       $this->queryRedirect() . ' ' .
                        $this->queryNamespaces()
                );
        }
@@ -267,8 +254,7 @@ class SearchSqlite extends SearchDatabase {
                $searchindex = $this->db->tableName( 'searchindex' );
                return "SELECT COUNT(*) AS c " .
                        "FROM $page,$searchindex " .
-                       "WHERE page_id=$searchindex.rowid AND $match" .
-                       $this->queryRedirect() . ' ' .
+                       "WHERE page_id=$searchindex.rowid AND $match " .
                        $this->queryNamespaces();
        }
 
index 3659c48..e406a0e 100644 (file)
@@ -60,11 +60,6 @@ class SpecialSearch extends SpecialPage {
         */
        protected $namespaces;
 
-       /**
-        * @var bool
-        */
-       protected $searchRedirects;
-
        /**
         * @var string
         */
@@ -159,9 +154,6 @@ class SpecialSearch extends SpecialPage {
                        }
                }
 
-               // Redirects defaults to true, but we don't know whether it was ticked of or just missing
-               $default = $request->getBool( 'profile' ) ? 0 : 1;
-               $this->searchRedirects = $request->getBool( 'redirs', $default ) ? 1 : 0;
                $this->didYouMeanHtml = ''; # html of did you mean... link
                $this->fulltext = $request->getVal( 'fulltext' );
                $this->profile = $profile;
@@ -219,8 +211,6 @@ class SpecialSearch extends SpecialPage {
                $search = $this->getSearchEngine();
                $search->setLimitOffset( $this->limit, $this->offset );
                $search->setNamespaces( $this->namespaces );
-               $search->showRedirects = $this->searchRedirects; // BC
-               $search->setFeatureData( 'list-redirects', $this->searchRedirects );
                $search->prefix = $this->mPrefix;
                $term = $search->transformSearchTerm( $term );
 
@@ -514,7 +504,6 @@ class SpecialSearch extends SpecialPage {
         */
        protected function powerSearchOptions() {
                $opt = array();
-               $opt['redirs'] = $this->searchRedirects ? 1 : 0;
                if ( $this->profile !== 'advanced' ) {
                        $opt['profile'] = $this->profile;
                } else {
@@ -872,7 +861,6 @@ class SpecialSearch extends SpecialPage {
        protected function getProfileForm( $profile, $term ) {
                // Hidden stuff
                $opts = array();
-               $opts['redirs'] = $this->searchRedirects;
                $opts['profile'] = $this->profile;
 
                if ( $profile === 'advanced' ) {
@@ -941,16 +929,9 @@ class SpecialSearch extends SpecialPage {
 
                $showSections = array( 'namespaceTables' => $namespaceTables );
 
-               // Show redirects check only if backend supports it
-               if ( $this->getSearchEngine()->supports( 'list-redirects' ) ) {
-                       $showSections['redirects'] =
-                               Xml::checkLabel( $this->msg( 'powersearch-redir' )->text(), 'redirs', 'redirs', $this->searchRedirects );
-               }
-
                wfRunHooks( 'SpecialSearchPowerBox', array( &$showSections, $term, $opts ) );
 
                $hidden = '';
-               unset( $opts['redirs'] );
                foreach ( $opts as $key => $value ) {
                        $hidden .= Html::hidden( $key, $value );
                }
@@ -1132,7 +1113,6 @@ class SpecialSearch extends SpecialPage {
                foreach ( $namespaces as $n ) {
                        $opt['ns' . $n] = 1;
                }
-               $opt['redirs'] = $this->searchRedirects;
 
                $stParams = array_merge(
                        array(