50 $this->searchTerms = [];
52 # @todo FIXME: This doesn't handle parenthetical expressions.
54 if ( preg_match_all(
'/([-+<>~]?)(([' . $lc .
']+)(\*?)|"[^"]*")/',
55 $filteredText, $m, PREG_SET_ORDER ) ) {
56 foreach ( $m as $bits ) {
57 MediaWiki\suppressWarnings();
58 list( , $modifier,
$term, $nonQuoted, $wildcard ) = $bits;
59 MediaWiki\restoreWarnings();
61 if ( $nonQuoted !=
'' ) {
69 if ( $searchon !==
'' ) {
72 if ( $this->strictMatching && ( $modifier ==
'' ) ) {
80 if ( is_array( $convertedVariants ) ) {
81 $variants = array_unique( array_values( $convertedVariants ) );
83 $variants = [
$term ];
90 $strippedVariants = array_map(
97 $strippedVariants = array_unique( $strippedVariants );
99 $searchon .= $modifier;
100 if ( count( $strippedVariants ) > 1 ) {
103 foreach ( $strippedVariants as $stripped ) {
105 if ( $nonQuoted && strpos( $stripped,
' ' ) !==
false ) {
109 $stripped =
'"' . trim( $stripped ) .
'"';
111 $searchon .=
"$quote$stripped$quote$wildcard ";
113 if ( count( $strippedVariants ) > 1 ) {
120 $this->searchTerms[] = $regexp;
122 wfDebug( __METHOD__ .
": Would search with '$searchon'\n" );
123 wfDebug( __METHOD__ .
': Match with /' . implode(
'|', $this->searchTerms ) .
"/\n" );
125 wfDebug( __METHOD__ .
": Can't understand search query '{$filteredText}'\n" );
128 $searchon = $this->db->addQuotes( $searchon );
130 return " MATCH($field) AGAINST($searchon IN BOOLEAN MODE) ";
136 $regex = preg_quote( $string,
'/' );
142 $regex =
"\b$regex\b";
153 $searchChars = parent::legalSearchChars(
$type );
154 if (
$type === self::CHARS_ALL ) {
156 $searchChars =
"\"*" . $searchChars;
183 if ( trim(
$term ) ===
'' ) {
189 $resultSet = $this->db->select(
196 $totalResult = $this->db->select(
201 $row = $totalResult->fetchObject();
203 $total = intval( $row->c );
205 $totalResult->free();
211 switch ( $feature ) {
212 case 'title-suffix-filter':
215 return parent::supports( $feature );
225 foreach ( $this->features as $feature =>
$value ) {
226 if ( $feature ===
'title-suffix-filter' &&
$value ) {
227 $query[
'conds'][] =
'page_title' . $this->db->buildLike( $this->db->anyString(),
$value );
287 return $fulltext ?
'si_text' :
'si_title';
299 $match = $this->
parseQuery( $filteredTerm, $fulltext );
300 $query[
'tables'][] =
'page';
301 $query[
'tables'][] =
'searchindex';
302 $query[
'fields'][] =
'page_id';
303 $query[
'fields'][] =
'page_namespace';
304 $query[
'fields'][] =
'page_title';
305 $query[
'conds'][] =
'page_id=si_page';
306 $query[
'conds'][] = $match;
316 $match = $this->
parseQuery( $filteredTerm, $fulltext );
319 'tables' => [
'page',
'searchindex' ],
320 'fields' => [
'COUNT(*) as c' ],
321 'conds' => [
'page_id=si_page', $match ],
342 $dbw->replace(
'searchindex',
361 $dbw->update(
'searchindex',
363 [
'si_page' => $id ],
365 [ $dbw->lowPriorityOption() ] );
378 $dbw->delete(
'searchindex', [
'si_page' => $id ], __METHOD__ );
390 $out = parent::normalizeText( $string );
394 $out = preg_replace_callback(
395 "/([\\xc0-\\xff][\\x80-\\xbf]*)/",
396 [ $this,
'stripForSearchCallback' ],
403 if ( $minLength > 1 ) {
432 return 'u8' . bin2hex(
$matches[1] );
442 if ( is_null( self::$mMinSearchLength ) ) {
443 $sql =
"SHOW GLOBAL VARIABLES LIKE 'ft\\_min\\_word\\_len'";
446 $result =
$dbr->query( $sql, __METHOD__ );
447 $row = $result->fetchObject();
450 if ( $row && $row->Variable_name ==
'ft_min_word_len' ) {
451 self::$mMinSearchLength = intval( $row->Value );
453 self::$mMinSearchLength = 0;
to move a page</td >< td > &*You are moving the page across namespaces
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Base search engine base class for database-backed searches.
filter( $text)
Return a 'cleaned up' search string.
Search engine hook for MySQL 4+.
parseQuery( $filteredText, $fulltext)
Parse the user's query and transform it into an SQL fragment which will become part of a WHERE clause...
queryMain(&$query, $filteredTerm, $fulltext)
Get the base part of the search query.
static legalSearchChars( $type=self::CHARS_ALL)
Get chars legal for search NOTE: usage as static is deprecated and preserved only as BC measure.
updateTitle( $id, $title)
Update a search index record's title only.
getQuery( $filteredTerm, $fulltext)
Construct the SQL query to do the search.
stripForSearchCallback( $matches)
Armor a case-folded UTF-8 string to get through MySQL's fulltext search without being mucked up by fu...
getIndexField( $fulltext)
Picks which field to index on, depending on what type of query.
queryFeatures(&$query)
Add special conditions.
update( $id, $title, $text)
Create or update the search index record for the given page.
searchInternal( $term, $fulltext)
limitResult(&$query)
Add limit options.
regexTerm( $string, $wildcard)
queryNamespaces(&$query)
Add namespace conditions.
searchText( $term)
Perform a full text search query and return a result set.
getCountQuery( $filteredTerm, $fulltext)
normalizeText( $string)
Converts some characters for MySQL's indexing to grok it correctly, and pads short words to overcome ...
minSearchLength()
Check MySQL server's ft_min_word_len setting so we know if we need to pad short words....
searchTitle( $term)
Perform a title-only search query and return a result set.
This class is used for different SQL-based search engines shipped with MediaWiki.
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
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
external whereas SearchGetNearMatch runs after $term
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
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