34 return $this->db->checkForEnabledSearch();
49 $this->searchTerms = [];
52 if ( preg_match_all(
'/([-+<>~]?)(([' . $lc .
']+)(\*?)|"[^"]*")/',
53 $filteredText, $m, PREG_SET_ORDER ) ) {
54 foreach ( $m
as $bits ) {
55 MediaWiki\suppressWarnings();
56 list( , $modifier,
$term, $nonQuoted, $wildcard ) = $bits;
57 MediaWiki\restoreWarnings();
59 if ( $nonQuoted !=
'' ) {
67 if ( $searchon !==
'' ) {
73 $convertedVariants = $wgContLang->autoConvertToAllVariants(
$term );
74 if ( is_array( $convertedVariants ) ) {
75 $variants = array_unique( array_values( $convertedVariants ) );
77 $variants = [
$term ];
84 $strippedVariants = array_map(
85 [ $wgContLang,
'normalizeForSearch' ],
91 $strippedVariants = array_unique( $strippedVariants );
93 $searchon .= $modifier;
94 if ( count( $strippedVariants ) > 1 ) {
97 foreach ( $strippedVariants
as $stripped ) {
98 if ( $nonQuoted && strpos( $stripped,
' ' ) !==
false ) {
102 $stripped =
'"' . trim( $stripped ) .
'"';
104 $searchon .=
"$quote$stripped$quote$wildcard ";
106 if ( count( $strippedVariants ) > 1 ) {
113 $this->searchTerms[] = $regexp;
117 wfDebug( __METHOD__ .
": Can't understand search query '{$filteredText}'\n" );
120 $searchon = $this->db->addQuotes( $searchon );
122 return " $field MATCH $searchon ";
128 $regex = preg_quote( $string,
'/' );
129 if ( $wgContLang->hasWordBreaks() ) {
134 $regex =
"\b$regex\b";
145 return "\"*" . parent::legalSearchChars();
175 $filteredTerm = $this->
filter( $wgContLang->lc(
$term ) );
176 $resultSet = $this->db->query( $this->
getQuery( $filteredTerm, $fulltext ) );
179 $totalResult = $this->db->query( $this->
getCountQuery( $filteredTerm, $fulltext ) );
180 $row = $totalResult->fetchObject();
182 $total = intval( $row->c );
184 $totalResult->free();
195 return ''; # search all
202 return 'AND page_namespace IN (' .
$namespaces .
')';
211 return $this->db->limitResult( $sql, $this->limit, $this->offset );
223 $this->
queryMain( $filteredTerm, $fulltext ) .
' ' .
234 return $fulltext ?
'si_text' :
'si_title';
245 $match = $this->
parseQuery( $filteredTerm, $fulltext );
246 $page = $this->db->tableName(
'page' );
247 $searchindex = $this->db->tableName(
'searchindex' );
248 return "SELECT $searchindex.rowid, page_namespace, page_title " .
249 "FROM $page,$searchindex " .
250 "WHERE page_id=$searchindex.rowid AND $match";
254 $match = $this->
parseQuery( $filteredTerm, $fulltext );
255 $page = $this->db->tableName(
'page' );
256 $searchindex = $this->db->tableName(
'searchindex' );
257 return "SELECT COUNT(*) AS c " .
258 "FROM $page,$searchindex " .
259 "WHERE page_id=$searchindex.rowid AND $match " .
279 $dbw->delete(
'searchindex', [
'rowid' => $id ], __METHOD__ );
281 $dbw->insert(
'searchindex',
302 $dbw->update(
'searchindex',
external whereas SearchGetNearMatch runs after $term
searchText($term)
Perform a full text search query and return a result set.
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
getCountQuery($filteredTerm, $fulltext)
parseQuery($filteredText, $fulltext)
Parse the user's query and transform it into an SQL fragment which will become part of a WHERE clause...
to move a page</td >< td > &*You are moving the page across namespaces
static legalSearchChars()
when a variable name is used in a it is silently declared as a new local masking the global
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
updateTitle($id, $title)
Update a search index record's title only.
update($id, $title, $text)
Create or update the search index record for the given page.
This class is used for different SQL-based search engines shipped with MediaWiki. ...
queryMain($filteredTerm, $fulltext)
Get the base part of the search query.
namespace and then decline to actually register it file or subcat img or subcat $title
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 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
fulltextSearchSupported()
Whether fulltext search is supported by current schema.
queryNamespaces()
Return a partial WHERE clause to limit the search to the given namespaces.
limitResult($sql)
Returns a query with limit for number of results set.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Base search engine base class for database-backed searches.
searchInternal($term, $fulltext)
searchTitle($term)
Perform a title-only search query and return a result set.
filter($text)
Return a 'cleaned up' search string.
getQuery($filteredTerm, $fulltext)
Construct the full SQL query to do the search.
Search engine hook for SQLite.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
regexTerm($string, $wildcard)
getIndexField($fulltext)
Picks which field to index on, depending on what type of query.