MediaWiki  1.33.0
Go to the documentation of this file.
1 <?php
11  protected $resultSet;
13  protected $terms;
15  protected $totalHits;
17  function __construct( ResultWrapper $resultSet, $terms, $total = null ) {
18  $this->resultSet = $resultSet;
19  $this->terms = $terms;
20  $this->totalHits = $total;
21  }
23  function termMatches() {
24  return $this->terms;
25  }
27  function numRows() {
28  if ( $this->resultSet === false ) {
29  return false;
30  }
32  return $this->resultSet->numRows();
33  }
35  public function extractResults() {
36  if ( $this->resultSet === false ) {
37  return [];
38  }
40  if ( $this->results === null ) {
41  $this->results = [];
42  $this->resultSet->rewind();
43  while ( ( $row = $this->resultSet->fetchObject() ) !== false ) {
44  $this->results[] = SearchResult::newFromTitle(
45  Title::makeTitle( $row->page_namespace, $row->page_title ), $this
46  );
47  }
48  }
49  return $this->results;
50  }
52  function free() {
53  if ( $this->resultSet === false ) {
54  return false;
55  }
57  $this->resultSet->free();
58  }
60  function getTotalHits() {
61  if ( !is_null( $this->totalHits ) ) {
62  return $this->totalHits;
63  } else {
64  // Special:Search expects a number here.
65  return $this->numRows();
66  }
67  }
68 }
Frees the result set, if applicable.
Definition: SqlSearchResultSet.php:52
int null $totalHits
Total number of hits for $terms.
Definition: SqlSearchResultSet.php:15
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Extract all the results in the result set as array.
Definition: SqlSearchResultSet.php:35
string $terms
Requested search query.
Definition: SqlSearchResultSet.php:13
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:576
Definition: SearchResultSet.php:27
ResultWrapper $resultSet
Result object from database.
Definition: SqlSearchResultSet.php:11
__construct(ResultWrapper $resultSet, $terms, $total=null)
Definition: SqlSearchResultSet.php:17
This class is used for different SQL-based search engines shipped with MediaWiki.
Definition: SqlSearchResultSet.php:9
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when you must cause when started running for such interactive use in the most ordinary to print or display an announcement including an appropriate copyright notice and a notice that there is no and telling the user how to view a copy of this and can be reasonably considered independent and separate works in then this and its terms
Definition: COPYING.txt:117
Fetch an array of regular expression fragments for matching the search terms as parsed by this engine...
Definition: SqlSearchResultSet.php:23
Definition: SqlSearchResultSet.php:27
static newFromTitle( $title, SearchResultSet $parentSet=null)
Return a new SearchResult and initializes it with a title.
Definition: SearchResult.php:72
SearchResult[] $results
Cache of results - serialization of the result iterator as an array.
Definition: SearchResultSet.php:56
Some search modes return a total hit count for the query in the entire article database.
Definition: SqlSearchResultSet.php:60