X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiOpenSearch.php;h=e6fe27ca2a34a1dce4c65bed46d5480034788137;hb=3287201b673c6e52c04e9f8771c0e71d1a617910;hp=066aaa3bca9aff7a2a08a119e92fbfa152fcdd98;hpb=476a926d79225402de952ec6977d2260e356d2f8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 066aaa3bca..e6fe27ca2a 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -272,20 +272,7 @@ class ApiOpenSearch extends ApiBase { if ( $this->allowedParams !== null ) { return $this->allowedParams; } - $this->allowedParams = [ - 'search' => null, - 'limit' => [ - ApiBase::PARAM_DFLT => $this->getConfig()->get( 'OpenSearchDefaultLimit' ), - ApiBase::PARAM_TYPE => 'limit', - ApiBase::PARAM_MIN => 1, - ApiBase::PARAM_MAX => 100, - ApiBase::PARAM_MAX2 => 100 - ], - 'namespace' => [ - ApiBase::PARAM_DFLT => NS_MAIN, - ApiBase::PARAM_TYPE => 'namespace', - ApiBase::PARAM_ISMULTI => true - ], + $this->allowedParams = $this->buildCommonApiParams( false ) + [ 'suggest' => false, 'redirects' => [ ApiBase::PARAM_TYPE => [ 'return', 'resolve' ], @@ -297,19 +284,21 @@ class ApiOpenSearch extends ApiBase { 'warningsaserror' => false, ]; - $profileParam = $this->buildProfileApiParam( SearchEngine::COMPLETION_PROFILE_TYPE, - 'apihelp-query+prefixsearch-param-profile' ); - if ( $profileParam ) { - $this->allowedParams['profile'] = $profileParam; - } + // Use open search specific default limit + $this->allowedParams['limit'][ApiBase::PARAM_DFLT] = $this->getConfig()->get( + 'OpenSearchDefaultLimit' + ); + return $this->allowedParams; } public function getSearchProfileParams() { - if ( isset( $this->getAllowedParams()['profile'] ) ) { - return [ SearchEngine::COMPLETION_PROFILE_TYPE => 'profile' ]; - } - return []; + return [ + 'profile' => [ + 'profile-type' => SearchEngine::COMPLETION_PROFILE_TYPE, + 'help-message' => 'apihelp-query+prefixsearch-param-profile' + ], + ]; } protected function getExamplesMessages() { @@ -402,14 +391,14 @@ class ApiOpenSearchFormatJson extends ApiFormatJson { } public function execute() { - if ( !$this->getResult()->getResultData( 'error' ) ) { - $result = $this->getResult(); - + $result = $this->getResult(); + if ( !$result->getResultData( 'error' ) && !$result->getResultData( 'errors' ) ) { // Ignore warnings or treat as errors, as requested $warnings = $result->removeValue( 'warnings', null ); if ( $this->warningsAsError && $warnings ) { - $this->dieUsage( - 'Warnings cannot be represented in OpenSearch JSON format', 'warnings', 0, + $this->dieWithError( + 'apierror-opensearch-json-warnings', + 'warnings', [ 'warnings' => $warnings ] ); }