if ( $nt ) {
$this->id = $id;
// is_string() check is back-compat for ApprovedRevs
- if( is_string( $c ) ) {
+ if ( is_string( $c ) ) {
$this->content = new TextContent( $c );
} else {
$this->content = $c ?: false;
wfProfileIn( __METHOD__ );
- $search = SearchEngine::create();
- $normalTitle = $search->normalizeText(
- Title::indexTitle( $this->title->getNamespace(), $this->title->getText() ) );
+ $page = WikiPage::newFromId( $this->id, WikiPage::READ_LATEST );
+ $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__ );
}