$flags: a comma-delimited list of strings representing the options used. May
include: utf8 (this will always be set for new revisions); gzip; external.
-'SearchUpdate': Prior to search update completion. Return false to stop any
-further text/content processing
-$id : Page id
-$title : Title object
-$text : Current text being indexed
-$content : Content object for text being indexed.
-
'SearchGetNearMatchBefore': Perform exact-title-matches in "go" searches before
the normal operations.
$allSearchTerms : Array of the search terms in all content languages
public function supports( $feature ) {
switch ( $feature ) {
case 'list-redirects':
+ case 'search-update':
return true;
case 'title-suffix-filter':
default:
public function getTextFromContent( Title $t, Content $c = null ) {
return $c ? $c->getTextForSearchIndex() : '';
}
+
+ /**
+ * If an implementation of SearchEngine handles all of its own text processing
+ * in getTextFromContent() and doesn't require SearchUpdate::updateText()'s
+ * rather silly handling, it should return true here instead.
+ *
+ * @return bool
+ */
+ public function textAlreadyUpdatedForIndex() {
+ return false;
+ }
}
/**
wfProfileIn( __METHOD__ );
- $search = SearchEngine::create();
- $normalTitle = $search->normalizeText(
- Title::indexTitle( $this->title->getNamespace(), $this->title->getText() ) );
+ $page = WikiPage::newFromId( $this->id );
+ $indexTitle = Title::indexTitle( $this->title->getNamespace(), $this->title->getText() );
- if ( WikiPage::newFromId( $this->id ) === null ) {
- $search->delete( $this->id, $normalTitle );
- wfProfileOut( __METHOD__ );
- return;
- } elseif ( $this->content === false ) {
- $search->updateTitle( $this->id, $normalTitle );
- wfProfileOut( __METHOD__ );
- return;
- }
+ foreach ( SearchEngine::getSearchTypes() as $type ) {
+ $search = SearchEngine::create( $type );
+ if ( !$search->supports( 'search-update' ) ) {
+ continue;
+ }
- $text = $search->getTextFromContent( $this->title, $this->content );
- if( wfRunHooks( 'SearchUpdate', array( $this->id, $this->title, &$text, $this->content ) ) ) {
- $text = self::updateText( $text );
- }
+ $normalTitle = $search->normalizeText( $indexTitle );
- # Perform the actual update
- $search->update( $this->id, $normalTitle, $search->normalizeText( $text ) );
+ if ( $page === null ) {
+ $search->delete( $this->id, $normalTitle );
+ continue;
+ } elseif ( $this->content === false ) {
+ $search->updateTitle( $this->id, $normalTitle );
+ continue;
+ }
+
+ $text = $search->getTextFromContent( $this->title, $this->content );
+ if ( !$search->textAlreadyUpdatedForIndex() ) {
+ $text = self::updateText( $text );
+ }
+
+ # Perform the actual update
+ $search->update( $this->id, $normalTitle, $search->normalizeText( $text ) );
+ }
wfProfileOut( __METHOD__ );
}