From: Robert Stojnić Date: Tue, 4 Nov 2008 22:19:37 +0000 (+0000) Subject: Recommit part of r42352 related to bug 5101 (Image from Commons doesn't show up when... X-Git-Tag: 1.31.0-rc.0~44427 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=3f183eafd5d32f5e702a525cea5ea6997744eef6;p=lhc%2Fweb%2Fwiklou.git Recommit part of r42352 related to bug 5101 (Image from Commons doesn't show up when searched in Wikipedia search box) --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bd4532f9e9..b7c22b0e12 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -315,6 +315,7 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 15737) Fix notices while expanding using PPCustomFrame * (bug 15544) Non-index entry points cause the "Wiki not set up" message to have corrupt URLs +* (bug 5101) Image from Commons doesn't show up when searched in Wikipedia search box === API changes in 1.14 === diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 1856b9e57a..85071d5c96 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -483,11 +483,15 @@ class SearchResultTooMany { */ class SearchResult { var $mRevision = null; + var $mImage = null; function SearchResult( $row ) { $this->mTitle = Title::makeTitle( $row->page_namespace, $row->page_title ); - if( !is_null($this->mTitle) ) + if( !is_null($this->mTitle) ){ $this->mRevision = Revision::newFromTitle( $this->mTitle ); + if($this->mTitle->getNamespace() == NS_IMAGE) + $this->mImage = wfFindFile( $this->mTitle ); + } } /** @@ -509,9 +513,7 @@ class SearchResult { * @access public */ function isMissingRevision(){ - if( !$this->mRevision ) - return true; - return false; + return !$this->mRevision && !$this->mImage; } /** @@ -534,7 +536,11 @@ class SearchResult { */ protected function initText(){ if( !isset($this->mText) ){ - $this->mText = $this->mRevision->getText(); + if($this->mRevision != null) + $this->mText = $this->mRevision->getText(); + else // TODO: can we fetch raw wikitext for commons images? + $this->mText = ''; + } } @@ -594,7 +600,11 @@ class SearchResult { * @return string timestamp */ function getTimestamp(){ - return $this->mRevision->getTimestamp(); + if( $this->mRevision ) + return $this->mRevision->getTimestamp(); + else if( $this->mImage ) + return $this->mImage->getTimestamp(); + return ''; } /**