From: Chad Horohoe Date: Wed, 15 Jan 2014 00:20:53 +0000 (-0800) Subject: Two fixups to SearchResult X-Git-Tag: 1.31.0-rc.0~17250^2 X-Git-Url: http://git.cyclocoop.org/%22.htmlspecialchars%28%24url_syndic%29.%22?a=commitdiff_plain;h=d109ff79e18faa2fb3e9c87a69f42fc4cd0f3f34;p=lhc%2Fweb%2Fwiklou.git Two fixups to SearchResult - Make variables protected. Only class that uses these is LuceneResult and it's fine - Don't bother constructing a new file object if we've already got one in memory (we likely do) Change-Id: I7973aff1e96297a2fea70392b765c93a8c884d52 --- diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 94d39a576f..9ebe5e7aa0 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -762,18 +762,22 @@ class SearchResult { /** * @var Revision */ - var $mRevision = null; - var $mImage = null; + protected $mRevision = null; + + /** + * @var File + */ + protected $mImage = null; /** * @var Title */ - var $mTitle; + protected $mTitle; /** * @var String */ - var $mText; + protected $mText; /** * Return a new SearchResult and initializes it with a title. @@ -840,10 +844,7 @@ class SearchResult { * @return Boolean */ function isBrokenTitle() { - if ( is_null( $this->mTitle ) ) { - return true; - } - return false; + return is_null( $this->mTitle ); } /** @@ -862,6 +863,14 @@ class SearchResult { return $this->mTitle; } + /** + * Get the file for this page, if one exists + * @return File|null + */ + function getFile() { + return $this->mImage; + } + /** * @return float|null if not supported */ diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 98ae6f51cd..802efebf8b 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -689,7 +689,8 @@ class SpecialSearch extends SpecialPage { // Include a thumbnail for media files... if ( $t->getNamespace() == NS_FILE ) { - $img = wfFindFile( $t ); + $img = $result->getFile(); + $img = $img ?: wfFindFile( $t ); if ( $img ) { $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) ); if ( $thumb ) {