X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchResult.php;h=1954e85c7e1180db88bc5d472edea5b86930d79f;hb=41355718e137b2ed88160ad5ddb4db50336d54d9;hp=a862e1727a83b8e38ce56fe4d5d19cbc6a355451;hpb=cceade3a0f57ffe488d26950cefca68f9e4daa02;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchResult.php b/includes/search/SearchResult.php index a862e1727a..1954e85c7e 100644 --- a/includes/search/SearchResult.php +++ b/includes/search/SearchResult.php @@ -51,11 +51,6 @@ class SearchResult { */ protected $mText; - /** - * @var SearchEngine - */ - protected $searchEngine; - /** * A function returning a set of extension data. * @var Closure|null @@ -96,7 +91,6 @@ class SearchResult { $this->mImage = $services->getRepoGroup()->findFile( $this->mTitle ); } } - $this->searchEngine = $services->newSearchEngine(); } /** @@ -104,7 +98,7 @@ class SearchResult { * * @return bool */ - function isBrokenTitle() { + public function isBrokenTitle() { return is_null( $this->mTitle ); } @@ -113,14 +107,14 @@ class SearchResult { * * @return bool */ - function isMissingRevision() { + public function isMissingRevision() { return !$this->mRevision && !$this->mImage; } /** * @return Title */ - function getTitle() { + public function getTitle() { return $this->mTitle; } @@ -128,7 +122,7 @@ class SearchResult { * Get the file for this page, if one exists * @return File|null */ - function getFile() { + public function getFile() { return $this->mImage; } @@ -138,8 +132,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 = ''; } @@ -150,35 +144,35 @@ class SearchResult { * @param string[] $terms Terms to highlight (this parameter is deprecated and ignored) * @return string Highlighted text snippet, null (and not '') if not supported */ - function getTextSnippet( $terms = [] ) { + public function getTextSnippet( $terms = [] ) { return ''; } /** * @return string Highlighted title, '' if not supported */ - function getTitleSnippet() { + public function getTitleSnippet() { return ''; } /** * @return string Highlighted redirect name (redirect to this page), '' if none or not supported */ - function getRedirectSnippet() { + public function getRedirectSnippet() { return ''; } /** * @return Title|null Title object for the redirect to this page, null if none or not supported */ - function getRedirectTitle() { + public function getRedirectTitle() { return null; } /** * @return string Highlighted relevant section name, null if none or not supported */ - function getSectionSnippet() { + public function getSectionSnippet() { return ''; } @@ -186,7 +180,7 @@ class SearchResult { * @return Title|null Title object (pagename+fragment) for the section, * null if none or not supported */ - function getSectionTitle() { + public function getSectionTitle() { return null; } @@ -200,7 +194,7 @@ class SearchResult { /** * @return string Timestamp */ - function getTimestamp() { + public function getTimestamp() { if ( $this->mRevision ) { return $this->mRevision->getTimestamp(); } elseif ( $this->mImage ) { @@ -212,7 +206,7 @@ class SearchResult { /** * @return int Number of words */ - function getWordCount() { + public function getWordCount() { $this->initText(); return str_word_count( $this->mText ); } @@ -220,7 +214,7 @@ class SearchResult { /** * @return int Size in bytes */ - function getByteSize() { + public function getByteSize() { $this->initText(); return strlen( $this->mText ); } @@ -228,14 +222,14 @@ class SearchResult { /** * @return string Interwiki prefix of the title (return iw even if title is broken) */ - function getInterwikiPrefix() { + public function getInterwikiPrefix() { return ''; } /** * @return string Interwiki namespace of the title (since we likely can't resolve it locally) */ - function getInterwikiNamespaceText() { + public function getInterwikiNamespaceText() { return ''; } @@ -243,7 +237,7 @@ class SearchResult { * Did this match file contents (eg: PDF/DJVU)? * @return bool */ - function isFileMatch() { + public function isFileMatch() { return false; }