X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdeferred%2FSearchUpdate.php;h=3625476398a486130d6ad7c5af686852f2a16b08;hp=2766bcb18586fdb052c2c7340343e67c7cb52731;hb=1dee28cb5f1efd6d9e14d6cc1d0c73c3f69269b4;hpb=89539f2aa1b158fdcc703ad053e2580cb97a6385 diff --git a/includes/deferred/SearchUpdate.php b/includes/deferred/SearchUpdate.php index 2766bcb185..3625476398 100644 --- a/includes/deferred/SearchUpdate.php +++ b/includes/deferred/SearchUpdate.php @@ -75,13 +75,14 @@ class SearchUpdate implements DeferrableUpdate { * Perform actual update for the entry */ public function doUpdate() { - $config = MediaWikiServices::getInstance()->getSearchEngineConfig(); + $services = MediaWikiServices::getInstance(); + $config = $services->getSearchEngineConfig(); if ( $config->getConfig()->get( 'DisableSearchUpdate' ) || !$this->id ) { return; } - $seFactory = MediaWikiServices::getInstance()->getSearchEngineFactory(); + $seFactory = $services->getSearchEngineFactory(); foreach ( $config->getSearchTypes() as $type ) { $search = $seFactory->create( $type ); if ( !$search->supports( 'search-update' ) ) { @@ -113,19 +114,20 @@ class SearchUpdate implements DeferrableUpdate { * If you're using a real search engine, you'll probably want to override * this behavior and do something nicer with the original wikitext. * @param string $text - * @param SearchEngine $se Search engine + * @param SearchEngine|null $se Search engine * @return string */ public function updateText( $text, SearchEngine $se = null ) { - global $wgContLang; - + $services = MediaWikiServices::getInstance(); + $contLang = $services->getContentLanguage(); # Language-specific strip/conversion - $text = $wgContLang->normalizeForSearch( $text ); - $se = $se ?: MediaWikiServices::getInstance()->newSearchEngine(); + $text = $contLang->normalizeForSearch( $text ); + $se = $se ?: $services->newSearchEngine(); $lc = $se->legalSearchChars() . '&#;'; + # Strip HTML markup $text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/", - ' ', $wgContLang->lc( " " . $text . " " ) ); # Strip HTML markup + ' ', $contLang->lc( " " . $text . " " ) ); $text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD", "\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings @@ -200,15 +202,14 @@ class SearchUpdate implements DeferrableUpdate { * @return string A stripped-down title string ready for the search index */ private function getNormalizedTitle( SearchEngine $search ) { - global $wgContLang; - + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); $ns = $this->title->getNamespace(); $title = $this->title->getText(); $lc = $search->legalSearchChars() . '&#;'; - $t = $wgContLang->normalizeForSearch( $title ); + $t = $contLang->normalizeForSearch( $title ); $t = preg_replace( "/[^{$lc}]+/", ' ', $t ); - $t = $wgContLang->lc( $t ); + $t = $contLang->lc( $t ); # Handle 's, s' $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );