Recommit part of r42352 related to bug 5101 (Image from Commons doesn't show up when...
authorRobert Stojnić <rainman@users.mediawiki.org>
Tue, 4 Nov 2008 22:19:37 +0000 (22:19 +0000)
committerRobert Stojnić <rainman@users.mediawiki.org>
Tue, 4 Nov 2008 22:19:37 +0000 (22:19 +0000)
RELEASE-NOTES
includes/SearchEngine.php

index bd4532f..b7c22b0 100644 (file)
@@ -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 ===
 
index 1856b9e..85071d5 100644 (file)
@@ -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 '';                      
        }
 
        /**