Merge "Localisation updates from http://translatewiki.net."
authorTranslation updater bot <l10n-bot@translatewiki.net>
Wed, 14 Aug 2013 19:31:16 +0000 (19:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 14 Aug 2013 19:31:16 +0000 (19:31 +0000)
docs/hooks.txt
includes/search/SearchEngine.php
includes/search/SearchUpdate.php

index 50b97a3..1f25b47 100644 (file)
@@ -1976,13 +1976,6 @@ $data: the data stored in old_text.  The meaning depends on $flags: if external
 $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
index bfe7dda..b691c75 100644 (file)
@@ -95,6 +95,7 @@ class SearchEngine {
        public function supports( $feature ) {
                switch ( $feature ) {
                case 'list-redirects':
+               case 'search-update':
                        return true;
                case 'title-suffix-filter':
                default:
@@ -557,6 +558,17 @@ class SearchEngine {
        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;
+       }
 }
 
 /**
index 7146917..22e4724 100644 (file)
@@ -89,27 +89,33 @@ class SearchUpdate implements DeferrableUpdate {
 
                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__ );
        }