summaryrefslogtreecommitdiff
path: root/includes/api/ApiOpenSearch.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/api/ApiOpenSearch.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/api/ApiOpenSearch.php')
-rw-r--r--includes/api/ApiOpenSearch.php34
1 files changed, 7 insertions, 27 deletions
diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php
index 315ace37..7fb045e3 100644
--- a/includes/api/ApiOpenSearch.php
+++ b/includes/api/ApiOpenSearch.php
@@ -40,11 +40,11 @@ class ApiOpenSearch extends ApiBase {
if ( in_array( $format, $allowed ) ) {
return $this->getMain()->createPrinterByName( $format );
}
+
return $this->getMain()->createPrinterByName( $allowed[0] );
}
public function execute() {
- global $wgEnableOpenSearchSuggest, $wgSearchSuggestCacheExpiry;
$params = $this->extractRequestParams();
$search = $params['search'];
$limit = $params['limit'];
@@ -52,35 +52,15 @@ class ApiOpenSearch extends ApiBase {
$suggest = $params['suggest'];
// Some script that was loaded regardless of wgEnableOpenSearchSuggest, likely cached.
- if ( $suggest && !$wgEnableOpenSearchSuggest ) {
+ if ( $suggest && !$this->getConfig()->get( 'EnableOpenSearchSuggest' ) ) {
$searches = array();
} else {
// Open search results may be stored for a very long time
- $this->getMain()->setCacheMaxAge( $wgSearchSuggestCacheExpiry );
+ $this->getMain()->setCacheMaxAge( $this->getConfig()->get( 'SearchSuggestCacheExpiry' ) );
$this->getMain()->setCacheMode( 'public' );
- $searches = PrefixSearch::titleSearch( $search, $limit,
- $namespaces );
-
- // if the content language has variants, try to retrieve fallback results
- $fallbackLimit = $limit - count( $searches );
- if ( $fallbackLimit > 0 ) {
- global $wgContLang;
-
- $fallbackSearches = $wgContLang->autoConvertToAllVariants( $search );
- $fallbackSearches = array_diff( array_unique( $fallbackSearches ), array( $search ) );
-
- foreach ( $fallbackSearches as $fbs ) {
- $fallbackSearchResult = PrefixSearch::titleSearch( $fbs, $fallbackLimit,
- $namespaces );
- $searches = array_merge( $searches, $fallbackSearchResult );
- $fallbackLimit -= count( $fallbackSearchResult );
-
- if ( $fallbackLimit == 0 ) {
- break;
- }
- }
- }
+ $searcher = new StringPrefixSearch;
+ $searches = $searcher->searchWithVariants( $search, $limit, $namespaces );
}
// Set top level elements
$result = $this->getResult();
@@ -92,7 +72,7 @@ class ApiOpenSearch extends ApiBase {
return array(
'search' => null,
'limit' => array(
- ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_DFLT => $this->getConfig()->get( 'OpenSearchDefaultLimit' ),
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => 100,
@@ -122,7 +102,7 @@ class ApiOpenSearch extends ApiBase {
}
public function getDescription() {
- return 'Search the wiki using the OpenSearch protocol';
+ return 'Search the wiki using the OpenSearch protocol.';
}
public function getExamples() {