*slap self* fix hit counts for title searches when counts in mysql are enabled.
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 28 Jul 2009 20:49:01 +0000 (20:49 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 28 Jul 2009 20:49:01 +0000 (20:49 +0000)
includes/SearchMySQL.php

index 3d04466..24ee4df 100644 (file)
@@ -148,14 +148,28 @@ class SearchMySQL extends SearchEngine {
         * @return MySQLSearchResultSet
         */
        function searchText( $term ) {
+               return $this->searchInternal( $term, true );
+       }
+
+       /**
+        * Perform a title-only search query and return a result set.
+        *
+        * @param $term String: raw search term
+        * @return MySQLSearchResultSet
+        */
+       function searchTitle( $term ) {
+               return $this->searchInternal( $term, false );
+       }
+       
+       protected function searchInternal( $term, $fulltext ) {
                global $wgSearchMySQLTotalHits;
                
                $filteredTerm = $this->filter( $term );
-               $resultSet = $this->db->query( $this->getQuery( $filteredTerm, true ) );
+               $resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) );
                
                $total = null;
                if( $wgSearchMySQLTotalHits ) {
-                       $totalResult = $this->db->query( $this->getCountQuery( $filteredTerm, true ) );
+                       $totalResult = $this->db->query( $this->getCountQuery( $filteredTerm, $fulltext ) );
                        $row = $totalResult->fetchObject();
                        if( $row ) {
                                $total = $row->c;
@@ -166,17 +180,6 @@ class SearchMySQL extends SearchEngine {
                return new MySQLSearchResultSet( $resultSet, $this->searchTerms, $total );
        }
 
-       /**
-        * Perform a title-only search query and return a result set.
-        *
-        * @param $term String: raw search term
-        * @return MySQLSearchResultSet
-        */
-       function searchTitle( $term ) {
-               $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ), false ) ) );
-               return new MySQLSearchResultSet( $resultSet, $this->searchTerms );
-       }
-
 
        /**
         * Return a partial WHERE clause to exclude redirects, if so set