Deprecate SearchEngine:getTextFromContent() and SearchEngine::textAlreadyUpdatedForIn...
authorDavid Causse <dcausse@wikimedia.org>
Thu, 1 Aug 2019 14:58:33 +0000 (16:58 +0200)
committerDavid Causse <dcausse@wikimedia.org>
Thu, 1 Aug 2019 15:59:32 +0000 (17:59 +0200)
It was just a wrapper to Content::getTextForSearchIndex(), simply use
this method rather than depending on (and sometimes constructing) a
SearchEngine.

Change-Id: I8541248ffdca303f0af3b959cf2f051dcb497925

RELEASE-NOTES-1.34
includes/deferred/SearchUpdate.php
includes/search/SearchEngine.php
includes/search/SearchResult.php

index b056551..8ecc469 100644 (file)
@@ -430,6 +430,11 @@ because of Phabricator reports.
   DEFAULT_CONTEXT_CHARS.
 * SearchUpdate constructor: passing a string as the title param and or a boolean
   or a string as the content will produce a deprecation warning.
+* SearchEngine::getTextFromContent() is deprecated, use getTextForSearchIndex()
+  directly from the Content object.
+* SearchEngine::textAlreadyUpdatedForIndex() is deprecated, given the
+  deprecation above this method is no longer needed/called and should not be
+  implemented by SearchEngine implementation.
 
 === Other changes in 1.34 ===
 * …
index f37e9a5..611469c 100644 (file)
@@ -99,10 +99,8 @@ class SearchUpdate implements DeferrableUpdate {
                                continue;
                        }
 
-                       $text = $search->getTextFromContent( $this->title, $this->content );
-                       if ( !$search->textAlreadyUpdatedForIndex() ) {
-                               $text = $this->updateText( $text, $search );
-                       }
+                       $text = $this->content !== null ? $this->content->getTextForSearchIndex() : '';
+                       $text = $this->updateText( $text, $search );
 
                        # Perform the actual update
                        $search->update( $this->id, $normalTitle, $search->normalizeText( $text ) );
index 151c0c6..87a7861 100644 (file)
@@ -489,6 +489,7 @@ abstract class SearchEngine {
         * @param Title $t Title we're indexing
         * @param Content|null $c Content of the page to index
         * @return string
+        * @deprecated since 1.34 use Content::getTextForSearchIndex directly
         */
        public function getTextFromContent( Title $t, Content $c = null ) {
                return $c ? $c->getTextForSearchIndex() : '';
@@ -500,6 +501,7 @@ abstract class SearchEngine {
         * rather silly handling, it should return true here instead.
         *
         * @return bool
+        * @deprecated since 1.34 no longer needed since getTextFromContent is being deprecated
         */
        public function textAlreadyUpdatedForIndex() {
                return false;
index 1d71c87..b924b29 100644 (file)
@@ -138,8 +138,8 @@ class SearchResult {
        protected function initText() {
                if ( !isset( $this->mText ) ) {
                        if ( $this->mRevision != null ) {
-                               $this->mText = $this->searchEngine->getTextFromContent(
-                                               $this->mTitle, $this->mRevision->getContent() );
+                               $content = $this->mRevision->getContent();
+                               $this->mText = $content !== null ? $content->getTextForSearchIndex() : '';
                        } else { // TODO: can we fetch raw wikitext for commons images?
                                $this->mText = '';
                        }