Merge "editintro given a css class of its own"
[lhc/web/wiklou.git] / includes / search / SearchMySQL.php
index c4d7d1e..8ff2640 100644 (file)
  * @ingroup Search
  */
 class SearchMySQL extends SearchDatabase {
-       var $strictMatching = true;
-       static $mMinSearchLength;
+       protected $strictMatching = true;
+
+       private static $mMinSearchLength;
 
        /**
         * Parse the user's query and transform it into an SQL fragment which will
         * become part of a WHERE clause
         *
-        * @param $filteredText string
-        * @param $fulltext string
+        * @param string $filteredText
+        * @param string $fulltext
         *
         * @return string
         */
        function parseQuery( $filteredText, $fulltext ) {
                global $wgContLang;
-               $lc = SearchEngine::legalSearchChars(); // Minus format chars
+
+               $lc = $this->legalSearchChars(); // Minus format chars
                $searchon = '';
                $this->searchTerms = array();
 
@@ -52,7 +54,9 @@ class SearchMySQL extends SearchDatabase {
                if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
                                $filteredText, $m, PREG_SET_ORDER ) ) {
                        foreach ( $m as $bits ) {
-                               @list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits;
+                               wfSuppressWarnings();
+                               list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits;
+                               wfRestoreWarnings();
 
                                if ( $nonQuoted != '' ) {
                                        $term = $nonQuoted;
@@ -121,9 +125,9 @@ class SearchMySQL extends SearchDatabase {
                        wfDebug( __METHOD__ . ": Can't understand search query '{$filteredText}'\n" );
                }
 
-               $searchon = $this->db->strencode( $searchon );
+               $searchon = $this->db->addQuotes( $searchon );
                $field = $this->getIndexField( $fulltext );
-               return " MATCH($field) AGAINST('$searchon' IN BOOLEAN MODE) ";
+               return " MATCH($field) AGAINST($searchon IN BOOLEAN MODE) ";
        }
 
        function regexTerm( $string, $wildcard ) {
@@ -152,8 +156,8 @@ class SearchMySQL extends SearchDatabase {
        /**
         * Perform a full text search query and return a result set.
         *
-        * @param string $term raw search term
-        * @return MySQLSearchResultSet
+        * @param string $term Raw search term
+        * @return SqlSearchResultSet
         */
        function searchText( $term ) {
                return $this->searchInternal( $term, true );
@@ -162,8 +166,8 @@ class SearchMySQL extends SearchDatabase {
        /**
         * Perform a title-only search query and return a result set.
         *
-        * @param string $term raw search term
-        * @return MySQLSearchResultSet
+        * @param string $term Raw search term
+        * @return SqlSearchResultSet
         */
        function searchTitle( $term ) {
                return $this->searchInternal( $term, false );
@@ -199,7 +203,7 @@ class SearchMySQL extends SearchDatabase {
                        $totalResult->free();
                }
 
-               return new MySQLSearchResultSet( $resultSet, $this->searchTerms, $total );
+               return new SqlSearchResultSet( $resultSet, $this->searchTerms, $total );
        }
 
        public function supports( $feature ) {
@@ -213,7 +217,7 @@ class SearchMySQL extends SearchDatabase {
 
        /**
         * Add special conditions
-        * @param $query Array
+        * @param array $query
         * @since 1.18
         */
        protected function queryFeatures( &$query ) {
@@ -226,7 +230,7 @@ class SearchMySQL extends SearchDatabase {
 
        /**
         * Add namespace conditions
-        * @param $query Array
+        * @param array $query
         * @since 1.18 (changed)
         */
        function queryNamespaces( &$query ) {
@@ -240,7 +244,7 @@ class SearchMySQL extends SearchDatabase {
 
        /**
         * Add limit options
-        * @param $query Array
+        * @param array $query
         * @since 1.18
         */
        protected function limitResult( &$query ) {
@@ -251,9 +255,9 @@ class SearchMySQL extends SearchDatabase {
        /**
         * Construct the SQL query to do the search.
         * The guts shoulds be constructed in queryMain()
-        * @param $filteredTerm String
-        * @param $fulltext Boolean
-        * @return Array
+        * @param string $filteredTerm
+        * @param bool $fulltext
+        * @return array
         * @since 1.18 (changed)
         */
        function getQuery( $filteredTerm, $fulltext ) {
@@ -275,8 +279,8 @@ class SearchMySQL extends SearchDatabase {
 
        /**
         * Picks which field to index on, depending on what type of query.
-        * @param $fulltext Boolean
-        * @return String
+        * @param bool $fulltext
+        * @return string
         */
        function getIndexField( $fulltext ) {
                return $fulltext ? 'si_text' : 'si_title';
@@ -285,9 +289,9 @@ class SearchMySQL extends SearchDatabase {
        /**
         * Get the base part of the search query.
         *
-        * @param &$query array Search query array
-        * @param $filteredTerm String
-        * @param $fulltext Boolean
+        * @param array &$query Search query array
+        * @param string $filteredTerm
+        * @param bool $fulltext
         * @since 1.18 (changed)
         */
        function queryMain( &$query, $filteredTerm, $fulltext ) {
@@ -326,9 +330,9 @@ class SearchMySQL extends SearchDatabase {
         * Create or update the search index record for the given page.
         * Title and text should be pre-processed.
         *
-        * @param $id Integer
-        * @param $title String
-        * @param $text String
+        * @param int $id
+        * @param string $title
+        * @param string $text
         */
        function update( $id, $title, $text ) {
                $dbw = wfGetDB( DB_MASTER );
@@ -345,8 +349,8 @@ class SearchMySQL extends SearchDatabase {
         * Update a search index record's title only.
         * Title should be pre-processed.
         *
-        * @param $id Integer
-        * @param $title String
+        * @param int $id
+        * @param string $title
         */
        function updateTitle( $id, $title ) {
                $dbw = wfGetDB( DB_MASTER );
@@ -362,8 +366,8 @@ class SearchMySQL extends SearchDatabase {
         * Delete an indexed page
         * Title should be pre-processed.
         *
-        * @param Integer $id Page id that was deleted
-        * @param String $title Title of page that was deleted
+        * @param int $id Page id that was deleted
+        * @param string $title Title of page that was deleted
         */
        function delete( $id, $title ) {
                $dbw = wfGetDB( DB_MASTER );
@@ -452,17 +456,3 @@ class SearchMySQL extends SearchDatabase {
                return self::$mMinSearchLength;
        }
 }
-
-/**
- * @ingroup Search
- */
-class MySQLSearchResultSet extends SqlSearchResultSet {
-       function __construct( $resultSet, $terms, $totalHits = null ) {
-               parent::__construct( $resultSet, $terms );
-               $this->mTotalHits = $totalHits;
-       }
-
-       function getTotalHits() {
-               return $this->mTotalHits;
-       }
-}