Merge "Move RELEASE-NOTES-1.31 into HISTORY"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 13 Jun 2018 16:36:58 +0000 (16:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 13 Jun 2018 16:36:58 +0000 (16:36 +0000)
includes/api/ApiQuerySearch.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json
languages/i18n/en.json

index 708c944..3d87a5f 100644 (file)
@@ -60,6 +60,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
 
                // Create search engine instance and set options
                $search = $this->buildSearchEngine( $params );
+               if ( isset( $params['sort'] ) ) {
+                       $search->setSort( $params['sort'] );
+               }
                $search->setFeatureData( 'rewrite', (bool)$params['enablerewrites'] );
                $search->setFeatureData( 'interwiki', (bool)$interwiki );
 
@@ -382,6 +385,20 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                        'enablerewrites' => false,
                ];
 
+               // If we have more than one engine the list of available sorts is
+               // difficult to represent. For now don't expose it.
+               $alternatives = MediaWiki\MediaWikiServices::getInstance()
+                       ->getSearchEngineConfig()
+                       ->getSearchTypes();
+               if ( count( $alternatives ) == 1 ) {
+                       $this->allowedParams['sort'] = [
+                               ApiBase::PARAM_DFLT => 'relevance',
+                               ApiBase::PARAM_TYPE => MediaWiki\MediaWikiServices::getInstance()
+                                       ->newSearchEngine()
+                                       ->getValidSorts(),
+                       ];
+               }
+
                return $this->allowedParams;
        }
 
index e1ba665..94e1ac6 100644 (file)
        "apihelp-query+search-param-interwiki": "Include interwiki results in the search, if available.",
        "apihelp-query+search-param-backend": "Which search backend to use, if not the default.",
        "apihelp-query+search-param-enablerewrites": "Enable internal query rewriting. Some search backends can rewrite the query into another which is thought to provide better results, for instance by correcting spelling errors.",
+       "apihelp-query+search-param-sort": "Set the sort order of returned results.",
        "apihelp-query+search-example-simple": "Search for <kbd>meaning</kbd>.",
        "apihelp-query+search-example-text": "Search texts for <kbd>meaning</kbd>.",
        "apihelp-query+search-example-generator": "Get page info about the pages returned for a search for <kbd>meaning</kbd>.",
index 3fcf499..1680bb8 100644 (file)
        "apihelp-query+search-param-interwiki": "{{doc-apihelp-param|query+search|interwiki}}",
        "apihelp-query+search-param-backend": "{{doc-apihelp-param|query+search|backend}}",
        "apihelp-query+search-param-enablerewrites": "{{doc-apihelp-param|query+search|enablerewrites}}",
+       "apihelp-query+search-param-sort": "{{doc-apihelp-param|query+search|sort}}",
        "apihelp-query+search-example-simple": "{{doc-apihelp-example|query+search}}",
        "apihelp-query+search-example-text": "{{doc-apihelp-example|query+search}}",
        "apihelp-query+search-example-generator": "{{doc-apihelp-example|query+search}}",
index e50512d..ee098dd 100644 (file)
        "rcfilters-empty-filter": "No active filters. All contributions are shown.",
        "rcfilters-filterlist-title": "Filters",
        "rcfilters-filterlist-whatsthis": "How do these work?",
-       "rcfilters-filterlist-feedbacklink": "Tell us what you think about these (new) filtering tools",
+       "rcfilters-filterlist-feedbacklink": "Tell us what you think about these filtering tools",
        "rcfilters-highlightbutton-title": "Highlight results",
        "rcfilters-highlightmenu-title": "Select a color",
        "rcfilters-highlightmenu-help": "Select a color to highlight this property",