X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchResultSet.php;h=69795e792b0b052333934ec89fff51c504faf4b1;hb=52017fad77be3ca263d90a28209f2d7d7871fb51;hp=8fb04e4a910882da85be844808c3917bd913a0ae;hpb=d7e568139f54286e38cb966b3e2ee4e1c8af5e2c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchResultSet.php b/includes/search/SearchResultSet.php index 8fb04e4a91..69795e792b 100644 --- a/includes/search/SearchResultSet.php +++ b/includes/search/SearchResultSet.php @@ -54,7 +54,7 @@ class SearchResultSet { * @return array */ function termMatches() { - return array(); + return []; } function numRows() { @@ -129,7 +129,7 @@ class SearchResultSet { /** * Return a result set of hits on other (multiple) wikis associated with this one * - * @return SearchResultSet + * @return SearchResultSet[] */ function getInterwikiResults( $type = self::SECONDARY_RESULTS ) { return null; @@ -154,6 +154,12 @@ class SearchResultSet { return false; } + /** + * Rewind result set back to begining + */ + function rewind() { + } + /** * Frees the result set, if applicable. */ @@ -171,89 +177,3 @@ class SearchResultSet { return $this->containedSyntax; } } - -/** - * This class is used for different SQL-based search engines shipped with MediaWiki - * @ingroup Search - */ -class SqlSearchResultSet extends SearchResultSet { - protected $resultSet; - protected $terms; - protected $totalHits; - - function __construct( $resultSet, $terms, $total = null ) { - $this->resultSet = $resultSet; - $this->terms = $terms; - $this->totalHits = $total; - } - - function termMatches() { - return $this->terms; - } - - function numRows() { - if ( $this->resultSet === false ) { - return false; - } - - return $this->resultSet->numRows(); - } - - function next() { - if ( $this->resultSet === false ) { - return false; - } - - $row = $this->resultSet->fetchObject(); - if ( $row === false ) { - return false; - } - - return SearchResult::newFromTitle( - Title::makeTitle( $row->page_namespace, $row->page_title ) - ); - } - - function free() { - if ( $this->resultSet === false ) { - return false; - } - - $this->resultSet->free(); - } - - function getTotalHits() { - if ( !is_null( $this->totalHits ) ) { - return $this->totalHits; - } else { - // Special:Search expects a number here. - return $this->numRows(); - } - } -} - -/** - * A SearchResultSet wrapper for SearchEngine::getNearMatch - */ -class SearchNearMatchResultSet extends SearchResultSet { - private $fetched = false; - - /** - * @param Title|null $match Title if matched, else null - */ - public function __construct( $match ) { - $this->result = $match; - } - - public function numRows() { - return $this->result ? 1 : 0; - } - - public function next() { - if ( $this->fetched || !$this->result ) { - return false; - } - $this->fetched = true; - return SearchResult::newFromTitle( $this->result ); - } -}