return;
}
- wfProfileIn( __METHOD__ );
-
- $page = WikiPage::newFromId( $this->id, WikiPage::READ_LATEST );
- $indexTitle = $this->indexTitle();
+ $page = WikiPage::newFromID( $this->id, WikiPage::READ_LATEST );
foreach ( SearchEngine::getSearchTypes() as $type ) {
$search = SearchEngine::create( $type );
+ $indexTitle = $this->indexTitle( $search );
if ( !$search->supports( 'search-update' ) ) {
continue;
}
$search->update( $this->id, $normalTitle, $search->normalizeText( $text ) );
}
- wfProfileOut( __METHOD__ );
}
/**
* Clean text for indexing. Only really suitable for indexing in databases.
* 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
+ * @return string
*/
public static function updateText( $text ) {
global $wgContLang;
$text = $wgContLang->normalizeForSearch( $text );
$lc = SearchEngine::legalSearchChars() . '&#;';
- wfProfileIn( __METHOD__ . '-regexps' );
$text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/",
' ', $wgContLang->lc( " " . $text . " " ) ); # Strip HTML markup
$text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD",
# Strip wiki '' and '''
$text = preg_replace( "/''[']*/", " ", $text );
- wfProfileOut( __METHOD__ . '-regexps' );
return $text;
}
* Get a string representation of a title suitable for
* including in a search index
*
+ * @param SearchEngine $search
* @return string A stripped-down title string ready for the search index
*/
- private function indexTitle() {
+ private function indexTitle( SearchEngine $search ) {
global $wgContLang;
$ns = $this->title->getNamespace();
$title = $this->title->getText();
- $lc = SearchEngine::legalSearchChars() . '&#;';
+ $lc = $search->legalSearchChars() . '&#;';
$t = $wgContLang->normalizeForSearch( $title );
$t = preg_replace( "/[^{$lc}]+/", ' ', $t );
$t = $wgContLang->lc( $t );