rm $wgCountTotalSearchHits. It was broken.
authorBrian Wolff <bawolff+wn@gmail.com>
Tue, 8 Jul 2014 06:35:56 +0000 (03:35 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Tue, 8 Jul 2014 06:41:13 +0000 (03:41 -0300)
If $wgCountTotalSearchHits was set to true, then the total
number of hits returned was zero, which caused Special:Search
to display no results.

I'm opting to remove the feature (although I don't have any
strong opinions about removal vs changing Special:Search), since
if someone both cares about performance and has a wiki where its
big enough to matter, they are going to need to use Cirrus anyways.

Change-Id: I1c3b908ae5423ce3dfbdc22b1a68dd81a85698aa

RELEASE-NOTES-1.24
includes/DefaultSettings.php
includes/search/SearchMySQL.php
includes/search/SearchResultSet.php
includes/search/SearchSqlite.php

index 9c605d0..f684822 100644 (file)
@@ -27,6 +27,9 @@ production.
   prefixes (i.e. turned into interlanguage links when $wgInterwikiMagic is set
   to true).
 * $wgParserTestRemote has been removed.
+* $wgCountTotalSearchHits has been removed. If you're concerned about efficiency
+  of search, you should use something like CirrusSearch instead of built in
+  search.
 
 === New features in 1.24 ===
 * Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
index 11196ae..fb73eb3 100644 (file)
@@ -5278,18 +5278,6 @@ $wgAdvancedSearchHighlighting = false;
  */
 $wgSearchHighlightBoundaries = '[\p{Z}\p{P}\p{C}]';
 
-/**
- * Set to true to have the search engine count total
- * search matches to present in the Special:Search UI.
- * Not supported by every search engine shipped with MW.
- *
- * This could however be slow on larger wikis, and is pretty flaky
- * with the current title vs content split. Recommend avoiding until
- * that's been worked out cleanly; but this may aid in testing the
- * search UI and API to confirm that the result count works.
- */
-$wgCountTotalSearchHits = false;
-
 /**
  * Template for OpenSearch suggestions, defaults to API action=opensearch
  *
index 8ff2640..581d8bc 100644 (file)
@@ -174,8 +174,6 @@ class SearchMySQL extends SearchDatabase {
        }
 
        protected function searchInternal( $term, $fulltext ) {
-               global $wgCountTotalSearchHits;
-
                // This seems out of place, why is this called with empty term?
                if ( trim( $term ) === '' ) {
                        return null;
@@ -189,19 +187,17 @@ class SearchMySQL extends SearchDatabase {
                );
 
                $total = null;
-               if ( $wgCountTotalSearchHits ) {
-                       $query = $this->getCountQuery( $filteredTerm, $fulltext );
-                       $totalResult = $this->db->select(
-                               $query['tables'], $query['fields'], $query['conds'],
-                               __METHOD__, $query['options'], $query['joins']
-                       );
-
-                       $row = $totalResult->fetchObject();
-                       if ( $row ) {
-                               $total = intval( $row->c );
-                       }
-                       $totalResult->free();
+               $query = $this->getCountQuery( $filteredTerm, $fulltext );
+               $totalResult = $this->db->select(
+                       $query['tables'], $query['fields'], $query['conds'],
+                       __METHOD__, $query['options'], $query['joins']
+               );
+
+               $row = $totalResult->fetchObject();
+               if ( $row ) {
+                       $total = intval( $row->c );
                }
+               $totalResult->free();
 
                return new SqlSearchResultSet( $resultSet, $this->searchTerms, $total );
        }
index f430dd0..698f93c 100644 (file)
@@ -173,7 +173,12 @@ class SqlSearchResultSet extends SearchResultSet {
        }
 
        function getTotalHits() {
-               return $this->totalHits;
+               if ( !is_null( $this->totalHits ) ) {
+                       return $this->totalHits;
+               } else {
+                       // Special:Search expects a number here.
+                       return $this->numRows();
+               }
        }
 }
 
index 8e820f3..05d5ca0 100644 (file)
@@ -164,7 +164,7 @@ class SearchSqlite extends SearchDatabase {
        }
 
        protected function searchInternal( $term, $fulltext ) {
-               global $wgCountTotalSearchHits, $wgContLang;
+               global $wgContLang;
 
                if ( !$this->fulltextSearchSupported() ) {
                        return null;
@@ -174,14 +174,12 @@ class SearchSqlite extends SearchDatabase {
                $resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) );
 
                $total = null;
-               if ( $wgCountTotalSearchHits ) {
-                       $totalResult = $this->db->query( $this->getCountQuery( $filteredTerm, $fulltext ) );
-                       $row = $totalResult->fetchObject();
-                       if ( $row ) {
-                               $total = intval( $row->c );
-                       }
-                       $totalResult->free();
+               $totalResult = $this->db->query( $this->getCountQuery( $filteredTerm, $fulltext ) );
+               $row = $totalResult->fetchObject();
+               if ( $row ) {
+                       $total = intval( $row->c );
                }
+               $totalResult->free();
 
                return new SqlSearchResultSet( $resultSet, $this->searchTerms, $total );
        }