Merge "Add a rewind function to SearchResultSet"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 14 Apr 2016 00:00:18 +0000 (00:00 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 14 Apr 2016 00:00:18 +0000 (00:00 +0000)
includes/search/SearchNearMatchResultSet.php
includes/search/SearchResultSet.php
includes/search/SqlSearchResultSet.php

index cb4f81d..510726b 100644 (file)
@@ -23,4 +23,8 @@ class SearchNearMatchResultSet extends SearchResultSet {
                $this->fetched = true;
                return SearchResult::newFromTitle( $this->result );
        }
+
+       public function rewind() {
+               $this->fetched = false;
+       }
 }
index bfee698..a673dba 100644 (file)
@@ -154,6 +154,12 @@ class SearchResultSet {
                return false;
        }
 
+       /**
+        * Rewind result set back to begining
+        */
+       function rewind() {
+       }
+
        /**
         * Frees the result set, if applicable.
         */
index 7a6aaf7..6b60899 100644 (file)
@@ -8,7 +8,7 @@ class SqlSearchResultSet extends SearchResultSet {
        protected $terms;
        protected $totalHits;
 
-       function __construct( $resultSet, $terms, $total = null ) {
+       function __construct( ResultWrapper $resultSet, $terms, $total = null ) {
                $this->resultSet = $resultSet;
                $this->terms = $terms;
                $this->totalHits = $total;
@@ -41,6 +41,12 @@ class SqlSearchResultSet extends SearchResultSet {
                );
        }
 
+       function rewind() {
+               if ( $this->resultSet ) {
+                       $this->resultSet->rewind();
+               }
+       }
+
        function free() {
                if ( $this->resultSet === false ) {
                        return false;