Go to the documentation of this file.
3 use Wikimedia\TestingAccessWrapper;
28 $this->
insertPage(
'Redirect test',
'#REDIRECT [[Redirect Test]]' );
30 $this->
insertPage(
'Redirect Test Worse Result' );
31 $this->
insertPage(
'Redirect test2',
'#REDIRECT [[Redirect Test2]]' );
32 $this->
insertPage(
'Redirect TEST2',
'#REDIRECT [[Redirect Test2]]' );
34 $this->
insertPage(
'Redirect Test2 Worse Result' );
50 $this->markTestSkipped(
'Main namespace does not support wikitext.' );
55 'wgSpecialPages' => [],
57 'wgExtraNamespaces' => [ self::NS_NONCAP =>
'NonCap' ],
58 'wgCapitalLinkOverrides' => [ self::NS_NONCAP =>
false ],
61 $this->originalHandlers = TestingAccessWrapper::newFromClass(
Hooks::class )->handlers;
62 TestingAccessWrapper::newFromClass(
Hooks::class )->handlers = [];
74 if ( $results ===
null ) {
78 'PrefixSearchBackend' => [
79 function (
$namespaces, $search, $limit, &$srchres )
use ( $results ) {
96 'Main namespace with title prefix',
109 'Talk namespace prefix',
117 'User namespace prefix',
124 'Special namespace prefix',
125 'query' =>
'Special:',
127 'Special:ActiveUsers',
128 'Special:AllMessages',
129 'Special:AllMyUploads',
137 'Special namespace with prefix',
138 'query' =>
'Special:Un',
141 'Special:UncategorizedCategories',
142 'Special:UncategorizedFiles',
146 'Special:UncategorizedPages',
151 'query' =>
'Special:EditWatchlist',
153 'Special:EditWatchlist',
157 'Special page subpages',
158 'query' =>
'Special:EditWatchlist/',
160 'Special:EditWatchlist/clear',
161 'Special:EditWatchlist/raw',
165 'Special page subpages with prefix',
166 'query' =>
'Special:EditWatchlist/cl',
168 'Special:EditWatchlist/clear',
172 'Namespace with case sensitive first letter',
173 'query' =>
'NonCap:upper',
177 'Multinamespace search',
186 'Multinamespace search with lowercase first letter',
211 sort( $case[
'results'], SORT_STRING );
240 sort( $case[
'results'], SORT_STRING );
244 array_shift( $case[
'results'] );
246 $expected = isset( $case[
'offsetresult'] ) ?
247 array_merge( $case[
'results'], $case[
'offsetresult'] ) :
274 'Exact match not on top (T72958)',
288 'Exact match missing (T72958)',
302 'Exact match missing and not existing',
316 "Exact match shouldn't override already found match if " .
317 "exact is redirect and found isn't",
320 'Redirect Test Worse Result',
323 'query' =>
'redirect test',
327 'Redirect Test Worse Result',
331 "Exact match shouldn't override already found match if " .
332 "both exact match and found match are redirect",
336 'Redirect Test2 Worse Result',
339 'query' =>
'redirect TEST2',
344 'Redirect Test2 Worse Result',
348 "Exact match should override any already found matches that " .
349 "are redirects to it",
353 'Redirect Test Worse Result',
356 'query' =>
'Redirect Test',
361 'Redirect Test Worse Result',
374 $results = $searcher->
search( $case[
'query'], 3 );
namespace and then decline to actually register it & $namespaces
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
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
search( $search, $limit, $namespaces=[], $offset=0)
Do a prefix search of titles and return a list of matching page names.
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
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
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))
testSearchWithOffset(array $case)
provideSearch PrefixSearch::search PrefixSearch::searchBackend
testSearchBackend(array $case)
provideSearchBackend PrefixSearch::searchBackend
static provideSearchBackend()
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
Search Database PrefixSearch.
Performs prefix search, returning strings.
searchProvision(array $results=null)
testSearch(array $case)
provideSearch PrefixSearch::search PrefixSearch::searchBackend