Go to the documentation of this file.
58 $search = trim( $search );
59 if ( $search ==
'' ) {
64 if ( $hasNamespace !==
false ) {
84 $fallbackLimit = $limit -
count( $searches );
85 if ( $fallbackLimit > 0 ) {
86 $fallbackSearches = MediaWikiServices::getInstance()->getContentLanguage()->
87 autoConvertToAllVariants( $search );
88 $fallbackSearches = array_diff( array_unique( $fallbackSearches ), [ $search ] );
90 foreach ( $fallbackSearches
as $fbs ) {
92 $searches = array_merge( $searches, $fallbackSearchResult );
93 $fallbackLimit -=
count( $fallbackSearchResult );
95 if ( $fallbackLimit == 0 ) {
141 'PrefixSearchBackend',
142 [
$namespaces, $search, $limit, &$srchres, $offset ]
151 if ( $offset === 0 ) {
157 $srchres = $rescorer->rescore( $search,
$namespaces, $srchres, $limit );
171 $searchParts = explode(
'/', $search, 2 );
172 $searchKey = $searchParts[0];
173 $subpageSearch = $searchParts[1] ??
null;
176 $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
177 if ( $subpageSearch !==
null ) {
180 if ( !$specialTitle ) {
183 $special = $spFactory->getPage( $specialTitle->getText() );
185 $subpages = $special->prefixSearchSubpages( $subpageSearch, $limit, $offset );
186 return array_map(
function ( $sub )
use ( $specialTitle ) {
187 return $specialTitle->getSubpage( $sub );
194 # normalize searchKey, so aliases with spaces can be found - T27675
195 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
196 $searchKey = str_replace(
' ',
'_', $searchKey );
197 $searchKey = $contLang->caseFold( $searchKey );
202 foreach ( $spFactory->getNames()
as $page ) {
203 $keys[$contLang->caseFold( $page )] = [
'page' => $page,
'rank' => 0 ];
206 foreach ( $contLang->getSpecialPageAliases()
as $page => $aliases ) {
207 if ( !in_array( $page, $spFactory->getNames() ) ) {# T22885
211 foreach ( $aliases
as $key => $alias ) {
212 $keys[$contLang->caseFold( $alias )] = [
'page' => $alias,
'rank' => $key ];
218 foreach (
$keys as $pageKey => $page ) {
219 if ( $searchKey ===
'' || strpos( $pageKey, $searchKey ) === 0 ) {
239 return array_slice(
$matches, $offset, $limit );
275 $prefixes[$prefix][] = $namespace;
285 'page_title' .
$dbr->buildLike( $prefix,
$dbr->anyString() ),
291 $fields = [
'page_id',
'page_namespace',
'page_title' ];
295 'ORDER BY' => [
'page_title',
'page_namespace' ],
312 $validNamespaces = MediaWikiServices::getInstance()->getContentLanguage()->getNamespaces();
316 if ( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) {
320 if (
count( $valid ) > 0 ) {
specialSearch( $search, $limit, $offset)
Prefix search special-case for Special: namespace.
static newFromResult( $res)
namespace and then decline to actually register it & $namespaces
handleResultFromHook( $srchres, $namespaces, $search, $limit, $offset)
static parseNamespacePrefixes( $query, $withAllKeyword=true, $withPrefixSearchExtractNamespaceHook=false)
Parse some common prefixes: all (search everything) or namespace names.
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
An utility class to rescore search results by looking for an exact match in the db and add the page f...
namespace and then decline to actually register it file or subcat img or subcat $title
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
searchWithVariants( $search, $limit, array $namespaces, $offset=0)
Do a prefix search for all possible variants of the prefix.
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.
strings(array $strings)
When implemented in a descendant class, receives an array of titles as strings and returns either an ...
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 titleSearch( $search, $limit, $namespaces=[], $offset=0)
Do a prefix search of titles and return a list of matching page names.
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))
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
validateNamespaces( $namespaces)
Validate an array of numerical namespace indexes.
searchBackend( $namespaces, $search, $limit, $offset)
Do a prefix search of titles and return a list of matching page names.
defaultSearchBackend( $namespaces, $search, $limit, $offset)
Unless overridden by PrefixSearchBackend hook...
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 & $options
Handles searching prefixes of titles and finding any page names that match.
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
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 MediaWikiServices
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Performs prefix search, returning strings.
titles(array $titles)
When implemented in a descendant class, receives an array of Title objects and returns either an unmo...