From 7e8c48ac3d11cff93c48b9c380897019eda225bd Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 13 Mar 2014 13:39:47 -0700 Subject: [PATCH] Remove "include redirects" option from search Always include redirects. Search results are worse without them and MWSearch has never respected this option anyway. Change-Id: I0ebe321a3b14e7960aa98e3225dc5a19ba916e7d --- RELEASE-NOTES-1.23 | 4 ++++ includes/api/ApiQuerySearch.php | 3 --- includes/search/SearchEngine.php | 2 -- includes/search/SearchMssql.php | 15 --------------- includes/search/SearchMySQL.php | 4 +--- includes/search/SearchOracle.php | 13 ------------- includes/search/SearchPostgres.php | 5 ----- includes/search/SearchSqlite.php | 16 +--------------- includes/specials/SpecialSearch.php | 20 -------------------- 9 files changed, 6 insertions(+), 76 deletions(-) diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 340aa505a4..c1a3ce0497 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -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) diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index fcaaf1033a..a2a15e0fb5 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -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' diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index a96ade007c..507a5200e6 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -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': diff --git a/includes/search/SearchMssql.php b/includes/search/SearchMssql.php index 15b5f1ce23..d92c9c8528 100644 --- a/includes/search/SearchMssql.php +++ b/includes/search/SearchMssql.php @@ -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 ) . ' ' ); } diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index c3edf5120f..c4d7d1e487 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -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 ); } } diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 2603161170..e14de2c1a5 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -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 ) . ' ' ); } diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 142e5fd884..4da63b3a28 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -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 ) { diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index ebff68ef1f..6b2b3c66ac 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -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(); } diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 3659c48ab9..e406a0ec32 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -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( -- 2.20.1