API: (bug 17142) Add redirects parameter to action=opensearch to control redirect...
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 27 Jan 2009 14:43:06 +0000 (14:43 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 27 Jan 2009 14:43:06 +0000 (14:43 +0000)
RELEASE-NOTES
includes/api/ApiOpenSearch.php

index 39e9e09..d0124ff 100644 (file)
@@ -107,6 +107,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 17069) Added ucshow=patrolled|!patrolled to list=usercontribs
 * action=delete respects $wgDeleteRevisionsLimit and the bigdelete user right
 * (bug 15949) Add undo functionality to action=edit
+* (bug 17142) Added redirects parameter to action=opensearch to control redirect
+  resolution
 
 === Languages updated in 1.15 ===
 
index 4a673c2..50e82c0 100644 (file)
@@ -51,6 +51,20 @@ class ApiOpenSearch extends ApiBase {
                $this->getMain()->setCacheMaxAge(1200);
 
                $srchres = PrefixSearch::titleSearch( $search, $limit, $namespaces );
+               
+               if( $params['redirects'] ) {
+                       foreach( $srchres as &$t ) {
+                               $title = Title::newFromText( $t );
+                               if( is_null( $title ) ) {
+                                       continue;
+                               }
+                               $article = new Article( $title );
+                               $redirTitle = $article->getRedirectTarget();
+                               if( !is_null( $redirTitle ) ) {
+                                       $t = $redirTitle->getPrefixedText();
+                               }
+                       }
+               }
 
                // Set top level elements
                $result = $this->getResult();
@@ -73,6 +87,7 @@ class ApiOpenSearch extends ApiBase {
                                ApiBase :: PARAM_TYPE => 'namespace',
                                ApiBase :: PARAM_ISMULTI => true
                        ),
+                       'redirects' => false,
                );
        }
 
@@ -81,6 +96,7 @@ class ApiOpenSearch extends ApiBase {
                        'search' => 'Search string',
                        'limit' => 'Maximum amount of results to return',
                        'namespace' => 'Namespaces to search',
+                       'redirects' => 'Resolve redirects',
                );
        }