* @ingroup Search
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Search engine hook for SQLite
* @ingroup Search
* @return string
*/
private function parseQuery( $filteredText, $fulltext ) {
- global $wgContLang;
$lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); // Minus syntax chars (" and *)
$searchon = '';
$this->searchTerms = [];
// Some languages such as Serbian store the input form in the search index,
// so we may need to search for matches in multiple writing system variants.
- $convertedVariants = $wgContLang->autoConvertToAllVariants( $term );
+ $convertedVariants = MediaWikiServices::getInstance()->getContentLanguage()->
+ autoConvertToAllVariants( $term );
if ( is_array( $convertedVariants ) ) {
$variants = array_unique( array_values( $convertedVariants ) );
} else {
// fulltext engine.
// For Chinese this also inserts spaces between adjacent Han characters.
$strippedVariants = array_map(
- [ $wgContLang, 'normalizeForSearch' ],
+ [ MediaWikiServices::getInstance()->getContentLanguage(),
+ 'normalizeForSearch' ],
$variants );
// Some languages such as Chinese force all variants to a canonical
}
private function regexTerm( $string, $wildcard ) {
- global $wgContLang;
-
$regex = preg_quote( $string, '/' );
- if ( $wgContLang->hasWordBreaks() ) {
+ if ( MediaWikiServices::getInstance()->getContentLanguage()->hasWordBreaks() ) {
if ( $wildcard ) {
// Don't cut off the final bit!
$regex = "\b$regex";
} else {
// For Chinese, words may legitimately abut other words in the text literal.
// Don't add \b boundary checks... note this could cause false positives
- // for latin chars.
+ // for Latin chars.
}
return $regex;
}
* @param string $term Raw search term
* @return SqlSearchResultSet
*/
- protected function doSearchText( $term ) {
+ protected function doSearchTextInDB( $term ) {
return $this->searchInternal( $term, true );
}
* @param string $term Raw search term
* @return SqlSearchResultSet
*/
- protected function doSearchTitle( $term ) {
+ protected function doSearchTitleInDB( $term ) {
return $this->searchInternal( $term, false );
}
protected function searchInternal( $term, $fulltext ) {
- global $wgContLang;
-
if ( !$this->fulltextSearchSupported() ) {
return null;
}
- $filteredTerm = $this->filter( $wgContLang->lc( $term ) );
+ $filteredTerm =
+ $this->filter( MediaWikiServices::getInstance()->getContentLanguage()->lc( $term ) );
$resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) );
$total = null;