MediaWiki  master
SearchEngineTest.php
Go to the documentation of this file.
1 <?php
2 
4 
13 
17  protected $search;
18 
23  protected function setUp() {
24  parent::setUp();
25 
26  // Search tests require MySQL or SQLite with FTS
27  $dbType = $this->db->getType();
28  $dbSupported = ( $dbType === 'mysql' )
29  || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
30 
31  if ( !$dbSupported ) {
32  $this->markTestSkipped( "MySQL or SQLite with FTS3 only" );
33  }
34 
35  $searchType = SearchEngineFactory::getSearchEngineClass( $this->db );
36  $this->setMwGlobals( [
37  'wgSearchType' => $searchType,
38  'wgCapitalLinks' => true,
39  'wgCapitalLinkOverrides' => [
40  NS_CATEGORY => false // for testCompletionSearchMustRespectCapitalLinkOverrides
41  ],
42  ] );
43 
44  $lb = LoadBalancerSingle::newFromConnection( $this->db );
45  $this->search = new $searchType( $lb );
46  }
47 
48  protected function tearDown() {
49  unset( $this->search );
50 
51  parent::tearDown();
52  }
53 
54  public function addDBDataOnce() {
55  if ( !$this->isWikitextNS( NS_MAIN ) ) {
56  // @todo cover the case of non-wikitext content in the main namespace
57  return;
58  }
59 
60  // Reset the search type back to default - some extensions may have
61  // overridden it.
62  $this->setMwGlobals( [
63  'wgSearchType' => null,
64  'wgCapitalLinks' => true,
65  'wgCapitalLinkOverrides' => [
66  NS_CATEGORY => false // for testCompletionSearchMustRespectCapitalLinkOverrides
67  ],
68  ] );
69 
70  $this->insertPage( 'Not_Main_Page', 'This is not a main page' );
71  $this->insertPage(
72  'Talk:Not_Main_Page',
73  'This is not a talk page to the main page, see [[smithee]]'
74  );
75  $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]' );
76  $this->insertPage( 'Talk:Smithee', 'This article sucks.' );
77  $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.' );
78  $this->insertPage( 'Another_page', 'This page also is unrelated.' );
79  $this->insertPage( 'Help:Help', 'Help me!' );
80  $this->insertPage( 'Thppt', 'Blah blah' );
81  $this->insertPage( 'Alan_Smithee', 'yum' );
82  $this->insertPage( 'Pages', 'are\'food' );
83  $this->insertPage( 'HalfOneUp', 'AZ' );
84  $this->insertPage( 'FullOneUp', 'AZ' );
85  $this->insertPage( 'HalfTwoLow', 'az' );
86  $this->insertPage( 'FullTwoLow', 'az' );
87  $this->insertPage( 'HalfNumbers', '1234567890' );
88  $this->insertPage( 'FullNumbers', '1234567890' );
89  $this->insertPage( 'DomainName', 'example.com' );
90  $this->insertPage( 'DomainName', 'example.com' );
91  $this->insertPage( 'Category:search is not Search', '' );
92  $this->insertPage( 'Category:Search is not search', '' );
93  }
94 
95  protected function fetchIds( $results ) {
96  if ( !$this->isWikitextNS( NS_MAIN ) ) {
97  $this->markTestIncomplete( __CLASS__ . " does no yet support non-wikitext content "
98  . "in the main namespace" );
99  }
100  $this->assertTrue( is_object( $results ) );
101 
102  $matches = [];
103  foreach ( $results as $row ) {
104  $matches[] = $row->getTitle()->getPrefixedText();
105  }
106  $results->free();
107  # Search is not guaranteed to return results in a certain order;
108  # sort them numerically so we will compare simply that we received
109  # the expected matches.
110  sort( $matches );
111 
112  return $matches;
113  }
114 
115  public function testFullWidth() {
116  $this->assertEquals(
117  [ 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ],
118  $this->fetchIds( $this->search->searchText( 'AZ' ) ),
119  "Search for normalized from Half-width Upper" );
120  $this->assertEquals(
121  [ 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ],
122  $this->fetchIds( $this->search->searchText( 'az' ) ),
123  "Search for normalized from Half-width Lower" );
124  $this->assertEquals(
125  [ 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ],
126  $this->fetchIds( $this->search->searchText( 'AZ' ) ),
127  "Search for normalized from Full-width Upper" );
128  $this->assertEquals(
129  [ 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ],
130  $this->fetchIds( $this->search->searchText( 'az' ) ),
131  "Search for normalized from Full-width Lower" );
132  }
133 
134  public function testTextSearch() {
135  $this->assertEquals(
136  [ 'Smithee' ],
137  $this->fetchIds( $this->search->searchText( 'smithee' ) ),
138  "Plain search" );
139  }
140 
141  public function testWildcardSearch() {
142  $res = $this->search->searchText( 'smith*' );
143  $this->assertEquals(
144  [ 'Smithee' ],
145  $this->fetchIds( $res ),
146  "Search with wildcards" );
147 
148  $res = $this->search->searchText( 'smithson*' );
149  $this->assertEquals(
150  [],
151  $this->fetchIds( $res ),
152  "Search with wildcards must not find unrelated articles" );
153 
154  $res = $this->search->searchText( 'smith* smithee' );
155  $this->assertEquals(
156  [ 'Smithee' ],
157  $this->fetchIds( $res ),
158  "Search with wildcards can be combined with simple terms" );
159 
160  $res = $this->search->searchText( 'smith* "one who smiths"' );
161  $this->assertEquals(
162  [ 'Smithee' ],
163  $this->fetchIds( $res ),
164  "Search with wildcards can be combined with phrase search" );
165  }
166 
167  public function testPhraseSearch() {
168  $res = $this->search->searchText( '"smithee is one who smiths"' );
169  $this->assertEquals(
170  [ 'Smithee' ],
171  $this->fetchIds( $res ),
172  "Search a phrase" );
173 
174  $res = $this->search->searchText( '"smithee is who smiths"' );
175  $this->assertEquals(
176  [],
177  $this->fetchIds( $res ),
178  "Phrase search is not sloppy, search terms must be adjacent" );
179 
180  $res = $this->search->searchText( '"is smithee one who smiths"' );
181  $this->assertEquals(
182  [],
183  $this->fetchIds( $res ),
184  "Phrase search is ordered" );
185  }
186 
187  public function testPhraseSearchHighlight() {
188  $phrase = "smithee is one who smiths";
189  $res = $this->search->searchText( "\"$phrase\"" );
190  $match = $res->getIterator()->current();
191  $snippet = "A <span class='searchmatch'>" . $phrase . "</span>";
192  $this->assertStringStartsWith( $snippet,
193  $match->getTextSnippet(),
194  "Highlight a phrase search" );
195  }
196 
197  public function testTextPowerSearch() {
198  $this->search->setNamespaces( [ 0, 1, 4 ] );
199  $this->assertEquals(
200  [
201  'Smithee',
202  'Talk:Not Main Page',
203  ],
204  $this->fetchIds( $this->search->searchText( 'smithee' ) ),
205  "Power search" );
206  }
207 
208  public function testTitleSearch() {
209  $this->assertEquals(
210  [
211  'Alan Smithee',
212  'Smithee',
213  ],
214  $this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
215  "Title search" );
216  }
217 
218  public function testTextTitlePowerSearch() {
219  $this->search->setNamespaces( [ 0, 1, 4 ] );
220  $this->assertEquals(
221  [
222  'Alan Smithee',
223  'Smithee',
224  'Talk:Smithee',
225  ],
226  $this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
227  "Title power search" );
228  }
229 
231  return [
232  'Searching for "smithee" finds Smithee on NS_MAIN' => [
233  'smithee',
234  'Smithee',
235  [ NS_MAIN ],
236  ],
237  'Searching for "search is" will finds "search is not Search" on NS_CATEGORY' => [
238  'search is',
239  'Category:search is not Search',
240  [ NS_CATEGORY ],
241  ],
242  'Searching for "Search is" will finds "search is not Search" on NS_CATEGORY' => [
243  'Search is',
244  'Category:Search is not search',
245  [ NS_CATEGORY ],
246  ],
247  ];
248  }
249 
262  $search,
263  $expectedSuggestion,
264  array $namespaces
265  ) {
266  $this->search->setNamespaces( $namespaces );
267  $results = $this->search->completionSearch( $search );
268  $this->assertEquals( 1, $results->getSize() );
269  $this->assertEquals( $expectedSuggestion, $results->getSuggestions()[0]->getText() );
270  }
271 
275  public function testSearchIndexFields() {
279  $mockEngine = $this->getMockBuilder( SearchEngine::class )
280  ->setMethods( [ 'makeSearchFieldMapping' ] )->getMock();
281 
282  $mockFieldBuilder = function ( $name, $type ) {
283  $mockField =
284  $this->getMockBuilder( SearchIndexFieldDefinition::class )->setConstructorArgs( [
285  $name,
286  $type,
287  ] )->getMock();
288 
289  $mockField->expects( $this->any() )->method( 'getMapping' )->willReturn( [
290  'testData' => 'test',
291  'name' => $name,
292  'type' => $type,
293  ] );
294 
295  $mockField->expects( $this->any() )
296  ->method( 'merge' )
297  ->willReturn( $mockField );
298 
299  return $mockField;
300  };
301 
302  $mockEngine->expects( $this->atLeastOnce() )
303  ->method( 'makeSearchFieldMapping' )
304  ->willReturnCallback( $mockFieldBuilder );
305 
306  // Not using mock since PHPUnit mocks do not work properly with references in params
307  $this->setTemporaryHook( 'SearchIndexFields',
308  function ( &$fields, SearchEngine $engine ) use ( $mockFieldBuilder ) {
309  $fields['testField'] =
310  $mockFieldBuilder( "testField", SearchIndexField::INDEX_TYPE_TEXT );
311  return true;
312  } );
313 
314  $fields = $mockEngine->getSearchIndexFields();
315  $this->assertArrayHasKey( 'language', $fields );
316  $this->assertArrayHasKey( 'category', $fields );
317  $this->assertInstanceOf( SearchIndexField::class, $fields['testField'] );
318 
319  $mapping = $fields['testField']->getMapping( $mockEngine );
320  $this->assertArrayHasKey( 'testData', $mapping );
321  $this->assertEquals( 'test', $mapping['testData'] );
322  }
323 
324  public function hookSearchIndexFields( $mockFieldBuilder, &$fields, SearchEngine $engine ) {
325  $fields['testField'] = $mockFieldBuilder( "testField", SearchIndexField::INDEX_TYPE_TEXT );
326  return true;
327  }
328 
329  public function testAugmentorSearch() {
330  $this->search->setNamespaces( [ 0, 1, 4 ] );
331  $resultSet = $this->search->searchText( 'smithee' );
332  // Not using mock since PHPUnit mocks do not work properly with references in params
333  $this->mergeMwGlobalArrayValue( 'wgHooks',
334  [ 'SearchResultsAugment' => [ [ $this, 'addAugmentors' ] ] ] );
335  $this->search->augmentSearchResults( $resultSet );
336  foreach ( $resultSet as $result ) {
337  $id = $result->getTitle()->getArticleID();
338  $augmentData = "Result:$id:" . $result->getTitle()->getText();
339  $augmentData2 = "Result2:$id:" . $result->getTitle()->getText();
340  $this->assertEquals( [ 'testSet' => $augmentData, 'testRow' => $augmentData2 ],
341  $result->getExtensionData() );
342  }
343  }
344 
345  public function addAugmentors( &$setAugmentors, &$rowAugmentors ) {
346  $setAugmentor = $this->createMock( ResultSetAugmentor::class );
347  $setAugmentor->expects( $this->once() )
348  ->method( 'augmentAll' )
349  ->willReturnCallback( function ( ISearchResultSet $resultSet ) {
350  $data = [];
352  foreach ( $resultSet as $result ) {
353  $id = $result->getTitle()->getArticleID();
354  $data[$id] = "Result:$id:" . $result->getTitle()->getText();
355  }
356  return $data;
357  } );
358  $setAugmentors['testSet'] = $setAugmentor;
359 
360  $rowAugmentor = $this->createMock( ResultAugmentor::class );
361  $rowAugmentor->expects( $this->exactly( 2 ) )
362  ->method( 'augment' )
363  ->willReturnCallback( function ( SearchResult $result ) {
364  $id = $result->getTitle()->getArticleID();
365  return "Result2:$id:" . $result->getTitle()->getText();
366  } );
367  $rowAugmentors['testRow'] = $rowAugmentor;
368  }
369 
370  public function testFiltersMissing() {
371  $availableResults = [];
372  foreach ( range( 0, 11 ) as $i ) {
373  $title = "Search_Result_$i";
374  $availableResults[] = $title;
375  // pages not created must be filtered
376  if ( $i % 2 == 0 ) {
377  $this->editSearchResultPage( $title );
378  }
379  }
380  MockCompletionSearchEngine::addMockResults( 'foo', $availableResults );
381 
383  $engine->setLimitOffset( 10, 0 );
384  $results = $engine->completionSearch( 'foo' );
385  $this->assertEquals( 5, $results->getSize() );
386  $this->assertTrue( $results->hasMoreResults() );
387 
388  $engine->setLimitOffset( 10, 10 );
389  $results = $engine->completionSearch( 'foo' );
390  $this->assertEquals( 1, $results->getSize() );
391  $this->assertFalse( $results->hasMoreResults() );
392  }
393 
394  private function editSearchResultPage( $title ) {
396  $page->doEditContent(
397  new WikitextContent( 'UTContent' ),
398  'UTPageSummary',
400  );
401  }
402 
404  return [
405  'noop' => [
406  [
407  'query' => 'foo',
408  ],
409  false,
410  ],
411  'empty' => [
412  [
413  'query' => '',
414  ],
415  false,
416  ],
417  'namespace prefix' => [
418  [
419  'query' => 'help:test',
420  ],
421  [ 'test', [ NS_HELP ] ],
422  ],
423  'accented namespace prefix with hook' => [
424  [
425  'query' => 'hélp:test',
426  'withHook' => true,
427  ],
428  [ 'test', [ NS_HELP ] ],
429  ],
430  'accented namespace prefix without hook' => [
431  [
432  'query' => 'hélp:test',
433  'withHook' => false,
434  ],
435  false,
436  ],
437  'all with all keyword allowed' => [
438  [
439  'query' => 'all:test',
440  'withAll' => true,
441  ],
442  [ 'test', null ],
443  ],
444  'all with all keyword disallowed' => [
445  [
446  'query' => 'all:test',
447  'withAll' => false,
448  ],
449  false,
450  ],
451  'ns only' => [
452  [
453  'query' => 'help:',
454  ],
455  [ '', [ NS_HELP ] ],
456  ],
457  'all only' => [
458  [
459  'query' => 'all:',
460  'withAll' => true,
461  ],
462  [ '', null ],
463  ],
464  'all wins over namespace when first' => [
465  [
466  'query' => 'all:help:test',
467  'withAll' => true,
468  ],
469  [ 'help:test', null ],
470  ],
471  'ns wins over all when first' => [
472  [
473  'query' => 'help:all:test',
474  'withAll' => true,
475  ],
476  [ 'all:test', [ NS_HELP ] ],
477  ],
478  ];
479  }
480 
488  public function testParseNamespacePrefix( array $params, $expected ) {
489  $this->setTemporaryHook( 'PrefixSearchExtractNamespace', function ( &$namespaces, &$query ) {
490  if ( strpos( $query, 'hélp:' ) === 0 ) {
491  $namespaces = [ NS_HELP ];
492  $query = substr( $query, strlen( 'hélp:' ) );
493  }
494  return false;
495  } );
496  $testSet = [];
497  if ( isset( $params['withAll'] ) && isset( $params['withHook'] ) ) {
498  $testSet[] = $params;
499  } elseif ( isset( $params['withAll'] ) ) {
500  $testSet[] = $params + [ 'withHook' => true ];
501  $testSet[] = $params + [ 'withHook' => false ];
502  } elseif ( isset( $params['withHook'] ) ) {
503  $testSet[] = $params + [ 'withAll' => true ];
504  $testSet[] = $params + [ 'withAll' => false ];
505  } else {
506  $testSet[] = $params + [ 'withAll' => true, 'withHook' => true ];
507  $testSet[] = $params + [ 'withAll' => true, 'withHook' => false ];
508  $testSet[] = $params + [ 'withAll' => false, 'withHook' => false ];
509  $testSet[] = $params + [ 'withAll' => true, 'withHook' => false ];
510  }
511 
512  foreach ( $testSet as $test ) {
513  $actual = SearchEngine::parseNamespacePrefixes( $test['query'],
514  $test['withAll'], $test['withHook'] );
515  $this->assertEquals( $expected, $actual, 'with params: ' . print_r( $test, true ) );
516  }
517  }
518 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:138
editSearchResultPage( $title)
the value to return A Title object or null for latest all implement SearchIndexField must implement ResultSetAugmentor & $rowAugmentors
Definition: hooks.txt:2886
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' 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:1529
const NS_MAIN
Definition: Defines.php:60
addAugmentors(&$setAugmentors, &$rowAugmentors)
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static parseNamespacePrefixes( $query, $withAllKeyword=true, $withPrefixSearchExtractNamespaceHook=false)
Parse some common prefixes: all (search everything) or namespace names.
testParseNamespacePrefix(array $params, $expected)
provideDataForParseNamespacePrefix
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\*-\*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1970
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1972
const INDEX_TYPE_TEXT
TEXT fields are suitable for natural language and may be subject to analysis such as stemming...
hookSearchIndexFields( $mockFieldBuilder, &$fields, SearchEngine $engine)
setUp()
Checks for database type & version.
$res
Definition: database.txt:21
testSearchIndexFields()
SearchEngine::getSearchIndexFields.
static addMockResults( $query, array $result)
Allows returning arbitrary lists of titles for completion search.
$params
const NS_CATEGORY
Definition: Defines.php:74
const EDIT_SUPPRESS_RC
Definition: Defines.php:135
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:912
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Search Database.
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition: hooks.txt:2886
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
const NS_HELP
Definition: Defines.php:72
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
const EDIT_NEW
Definition: Defines.php:132
static getSearchEngineClass( $dbOrLb)
SearchEngine implementation for returning mocked completion search results.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
provideCompletionSearchMustRespectCapitalLinkOverrides()
SearchEngine $search
testCompletionSearchMustRespectCapitalLinkOverrides( $search, $expectedSuggestion, array $namespaces)
Test that the search query is not munged using wrong CapitalLinks setup (in other test that the defau...
$matches
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:322