Remove/actualize unused imports
[lhc/web/wiklou.git] / includes / api / ApiQuerySearch.php
index 4377831..ba60da9 100644 (file)
@@ -24,8 +24,6 @@
  * @file
  */
 
-use MediaWiki\MediaWikiServices;
-
 /**
  * Query module to perform full text search within wiki titles and content
  *
@@ -37,14 +35,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
        /** @var array list of api allowed params */
        private $allowedParams;
 
-       /**
-        * When $wgSearchType is null, $wgSearchAlternatives[0] is null. Null isn't
-        * a valid option for an array for PARAM_TYPE, so we'll use a fake name
-        * that can't possibly be a class name and describes what the null behavior
-        * does
-        */
-       const BACKEND_NULL_PARAM = 'database-backed';
-
        public function __construct( ApiQuery $query, $moduleName ) {
                parent::__construct( $query, $moduleName, 'sr' );
        }
@@ -65,10 +55,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                global $wgContLang;
                $params = $this->extractRequestParams();
 
-               if ( isset( $params['backend'] ) && $params['backend'] == self::BACKEND_NULL_PARAM ) {
-                       unset( $params['backend'] );
-               }
-
                // Extract parameters
                $query = $params['search'];
                $what = $params['what'];
@@ -247,7 +233,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                                $vals = [
                                                        'namespace' => $result->getInterwikiNamespaceText(),
                                                        'title' => $title->getText(),
-                                                       'url' => $title->getFullUrl(),
+                                                       'url' => $title->getFullURL(),
                                                ];
 
                                                // Add item to results and see whether it fits
@@ -308,16 +294,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                        return $this->allowedParams;
                }
 
-               $this->allowedParams = [
-                       'search' => [
-                               ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
-                       ],
-                       'namespace' => [
-                               ApiBase::PARAM_DFLT => NS_MAIN,
-                               ApiBase::PARAM_TYPE => 'namespace',
-                               ApiBase::PARAM_ISMULTI => true,
-                       ],
+               $this->allowedParams = $this->buildCommonApiParams() + [
                        'what' => [
                                ApiBase::PARAM_TYPE => [
                                        'title',
@@ -354,52 +331,20 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
                        ],
-                       'offset' => [
-                               ApiBase::PARAM_DFLT => 0,
-                               ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
-                       ],
-                       'limit' => [
-                               ApiBase::PARAM_DFLT => 10,
-                               ApiBase::PARAM_TYPE => 'limit',
-                               ApiBase::PARAM_MIN => 1,
-                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
-                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
-                       ],
                        'interwiki' => false,
                        'enablerewrites' => false,
                ];
 
-               $searchConfig = MediaWikiServices::getInstance()->getSearchEngineConfig();
-               $alternatives = $searchConfig->getSearchTypes();
-               if ( count( $alternatives ) > 1 ) {
-                       if ( $alternatives[0] === null ) {
-                               $alternatives[0] = self::BACKEND_NULL_PARAM;
-                       }
-                       $this->allowedParams['backend'] = [
-                               ApiBase::PARAM_DFLT => $searchConfig->getSearchType(),
-                               ApiBase::PARAM_TYPE => $alternatives,
-                       ];
-                       // @todo: support profile selection when multiple
-                       // backends are available. The solution could be to
-                       // merge all possible profiles and let ApiBase
-                       // subclasses do the check. Making ApiHelp and ApiSandbox
-                       // comprehensive might be more difficult.
-               } else {
-                       $profileParam = $this->buildProfileApiParam( SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE,
-                               'apihelp-query+search-param-qiprofile' );
-                       if ( $profileParam ) {
-                               $this->allowedParams['qiprofile'] = $profileParam;
-                       }
-               }
-
                return $this->allowedParams;
        }
 
        public function getSearchProfileParams() {
-               if ( isset( $this->getAllowedParams()['qiprofile'] ) ) {
-                       return [ SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE => 'qiprofile' ];
-               }
-               return [];
+               return [
+                       'qiprofile' => [
+                               'profile-type' => SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE,
+                               'help-message' => 'apihelp-query+search-param-qiprofile',
+                       ],
+               ];
        }
 
        protected function getExamplesMessages() {