X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiOpenSearch.php;h=8e2837b3246642a5a10b3cfaca0fbc2eed137b86;hp=419fd140d70f5f774b78a2f4efae140c27364ca5;hb=821a4e84dddf89e903db953246cc638cf97294ad;hpb=f4a53c54065c385172363416eb3cb44b67585ca2 diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 419fd140d7..8e2837b324 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -1,7 +1,5 @@ @gmail.com" * Copyright © 2008 Brion Vibber * Copyright © 2014 Wikimedia Foundation and contributors @@ -381,38 +379,3 @@ class ApiOpenSearch extends ApiBase { } } } - -class ApiOpenSearchFormatJson extends ApiFormatJson { - private $warningsAsError = false; - - public function __construct( ApiMain $main, $fm, $warningsAsError ) { - parent::__construct( $main, "json$fm" ); - $this->warningsAsError = $warningsAsError; - } - - public function execute() { - $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->dieWithError( - 'apierror-opensearch-json-warnings', - 'warnings', - [ 'warnings' => $warnings ] - ); - } - - // Ignore any other unexpected keys (e.g. from $wgDebugToolbar) - $remove = array_keys( array_diff_key( - $result->getResultData(), - [ 0 => 'search', 1 => 'terms', 2 => 'descriptions', 3 => 'urls' ] - ) ); - foreach ( $remove as $key ) { - $result->removeValue( $key, null ); - } - } - - parent::execute(); - } -}