From: Roan Kattouw Date: Tue, 27 Jan 2009 14:43:06 +0000 (+0000) Subject: API: (bug 17142) Add redirects parameter to action=opensearch to control redirect... X-Git-Tag: 1.31.0-rc.0~43216 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=41cc3f6271ac2354d989d95b386ddb4bfe8f4487;p=lhc%2Fweb%2Fwiklou.git API: (bug 17142) Add redirects parameter to action=opensearch to control redirect resolution. Changes to OpenSearchXML extension in next commit --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 39e9e090b2..d0124ffe48 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 4a673c2154..50e82c05ca 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -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', ); }