r52854 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r52853 | r52854 (on ViewVC) | r52855 >
Date:20:17, 7 July 2009
Author:catrope
Status:ok
Tags:wmf-deployment 
Comment:API: Add snippet field to list=search output
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuerySearch.php
===================================================================
--- trunk/phase3/includes/api/ApiQuerySearch.php	(revision 52853)
+++ trunk/phase3/includes/api/ApiQuerySearch.php	(revision 52854)
@@ -48,7 +48,7 @@
 	}
 
 	private function run($resultPageSet = null) {
-
+		global $wgContLang;
 		$params = $this->extractRequestParams();
 
 		$limit = $params['limit'];
@@ -87,6 +87,7 @@
 			$this->dieUsage("{$what} search is disabled",
 					"search-{$what}-disabled");
 
+		$terms = $wgContLang->convertForSearchResult($matches->termMatches());
 		$titles = array ();
 		$count = 0;
 		while( $result = $matches->next() ) {
@@ -104,6 +105,7 @@
 			if (is_null($resultPageSet)) {
 				$vals = array();
 				ApiQueryBase::addTitleInfo($vals, $title);
+				$vals['snippet'] = $result->getTextSnippet($terms);
 				$fit = $this->getResult()->addValue(array('query', $this->getModuleName()), null, $vals);
 				if(!$fit)
 				{
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 52853)
+++ trunk/phase3/RELEASE-NOTES	(revision 52854)
@@ -268,6 +268,7 @@
 * (bug 18720) Add anchor field to action=parse&prop=sections output
 * (bug 19423) The initial file description page used caption in user lang
   rather than UI lang
+* Added snippet field to list=search output
 
 === Languages updated in 1.16 ===
 

Follow-up revisions

RevisionCommit summaryAuthorDate
r53905Merge r52854, r53904 to deployment -- API search enhancementsbrion21:30, 28 July 2009

Status & tagging log

Views
Toolbox