From 63e199226dce97214d1bc23a6c1c43eaa0487924 Mon Sep 17 00:00:00 2001 From: David Causse Date: Thu, 1 Aug 2019 16:58:33 +0200 Subject: [PATCH] Deprecate SearchEngine:getTextFromContent() and SearchEngine::textAlreadyUpdatedForIndex() 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 | 5 +++++ includes/deferred/SearchUpdate.php | 6 ++---- includes/search/SearchEngine.php | 2 ++ includes/search/SearchResult.php | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index b056551022..8ecc469d67 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -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 === * … diff --git a/includes/deferred/SearchUpdate.php b/includes/deferred/SearchUpdate.php index f37e9a50e5..611469c79c 100644 --- a/includes/deferred/SearchUpdate.php +++ b/includes/deferred/SearchUpdate.php @@ -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 ) ); diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 151c0c60da..87a7861b3a 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -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; diff --git a/includes/search/SearchResult.php b/includes/search/SearchResult.php index 1d71c87f9b..b924b29cff 100644 --- a/includes/search/SearchResult.php +++ b/includes/search/SearchResult.php @@ -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 = ''; } -- 2.20.1