Merge "Make the global objects documentation consistent in Setup.php"
[lhc/web/wiklou.git] / includes / search / SearchPostgres.php
index 4da63b3..43fb016 100644 (file)
@@ -34,7 +34,7 @@ class SearchPostgres extends SearchDatabase {
         * Currently searches a page's current title (page.page_title) and
         * latest revision article text (pagecontent.old_text)
         *
-        * @param string $term raw search term
+        * @param string $term Raw search term
         * @return PostgresSearchResultSet
         */
        function searchTitle( $term ) {
@@ -42,10 +42,6 @@ class SearchPostgres extends SearchDatabase {
                $olderror = error_reporting( E_ERROR );
                $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
                error_reporting( $olderror );
-               if ( !$resultSet ) {
-                       // Needed for "Query requires full scan, GIN doesn't support it"
-                       return new SearchResultTooMany();
-               }
                return new PostgresSearchResultSet( $resultSet, $this->searchTerms );
        }
 
@@ -54,9 +50,6 @@ class SearchPostgres extends SearchDatabase {
                $olderror = error_reporting( E_ERROR );
                $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
                error_reporting( $olderror );
-               if ( !$resultSet ) {
-                       return new SearchResultTooMany();
-               }
                return new PostgresSearchResultSet( $resultSet, $this->searchTerms );
        }
 
@@ -64,7 +57,7 @@ class SearchPostgres extends SearchDatabase {
         * Transform the user's search string into a better form for tsearch2
         * Returns an SQL fragment consisting of quoted text to search for.
         *
-        * @param $term string
+        * @param string $term
         *
         * @return string
         */
@@ -130,9 +123,9 @@ class SearchPostgres extends SearchDatabase {
 
        /**
         * Construct the full SQL query to do the search.
-        * @param $term String
-        * @param $fulltext String
-        * @param $colname
+        * @param string $term
+        * @param string $fulltext
+        * @param string $colname
         * @return string
         */
        function searchQuery( $term, $fulltext, $colname ) {
@@ -191,7 +184,7 @@ class SearchPostgres extends SearchDatabase {
 
        function update( $pageid, $title, $text ) {
                ## We don't want to index older revisions
-               $sql = "UPDATE pagecontent SET textvector = NULL WHERE old_id IN " .
+               $sql = "UPDATE pagecontent SET textvector = NULL WHERE textvector IS NOT NULL and old_id IN " .
                                "(SELECT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) .
                                " ORDER BY rev_text_id DESC OFFSET 1)";
                $this->db->query( $sql );
@@ -222,12 +215,8 @@ class PostgresSearchResult extends SearchResult {
  * @ingroup Search
  */
 class PostgresSearchResultSet extends SqlSearchResultSet {
-       function __construct( $resultSet, $terms ) {
-               parent::__construct( $resultSet, $terms );
-       }
-
        function next() {
-               $row = $this->mResultSet->fetchObject();
+               $row = $this->resultSet->fetchObject();
                if ( $row === false ) {
                        return false;
                } else {