MediaWiki REL1_33
MockSearchEngine.php
Go to the documentation of this file.
1<?php
2
4
7 private static $results = [];
9 private static $interwikiResults = [];
10
11 public static function clearMockResults() {
12 self::$results = [];
13 self::$interwikiResults = [];
14 }
15
21 public static function addMockResults( $query, array $results ) {
22 $lc = MediaWikiServices::getInstance()->getLinkCache();
23 foreach ( $results as &$result ) {
24 // Resolve deferred results; needed to work around T203279
25 if ( is_callable( $result ) ) {
26 $result = $result();
27 }
28
29 // TODO: better page ids? Does it matter?
30 $lc->addGoodLinkObj( mt_rand(), $result->getTitle() );
31 }
32 self::$results[$query] = $results;
33 }
34
39 self::$interwikiResults = $interwikiResults;
40 }
41
42 protected function doSearchText( $term ) {
43 if ( isset( self::$results[ $term ] ) ) {
44 $results = array_slice( self::$results[ $term ], $this->offset, $this->limit );
45 } else {
46 $results = [];
47 }
48 return new MockSearchResultSet( $results, self::$interwikiResults );
49 }
50}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
MediaWikiServices is the service locator for the application scope of MediaWiki.
static SearchResult[][] $results
doSearchText( $term)
Perform a full text search query and return a result set.
static setMockInterwikiResults(array $interwikiResults)
static addMockResults( $query, array $results)
static SearchResultSet[][] $interwikiResults
Contain a class for special pages.
namespace being checked & $result
Definition hooks.txt:2340
whereas SearchGetNearMatch runs after $term
Definition hooks.txt:2889
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1617
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))