summaryrefslogtreecommitdiff
path: root/includes/api/ApiOpenSearch.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:47 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:47 -0400
commit7e85254903c7c0cb49e381f16b18441ea7b058cc (patch)
treeb22328fcf4c8408fc25a7acb73d1cb1089cd82ac /includes/api/ApiOpenSearch.php
parent1de335ad3f395ca6861085393ba366a9e3fb4a0d (diff)
parent1a365e77dfb8825136626202b1df462731b42060 (diff)
Merge commit '1a365e'
Diffstat (limited to 'includes/api/ApiOpenSearch.php')
-rw-r--r--includes/api/ApiOpenSearch.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php
index a93b7cc6..0adb464d 100644
--- a/includes/api/ApiOpenSearch.php
+++ b/includes/api/ApiOpenSearch.php
@@ -384,13 +384,25 @@ class ApiOpenSearchFormatJson extends ApiFormatJson {
public function execute() {
if ( !$this->getResult()->getResultData( 'error' ) ) {
- $warnings = $this->getResult()->removeValue( 'warnings', null );
+ $result = $this->getResult();
+
+ // 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,
array( 'warnings' => $warnings )
);
}
+
+ // Ignore any other unexpected keys (e.g. from $wgDebugToolbar)
+ $remove = array_keys( array_diff_key(
+ $result->getResultData(),
+ array( 0 => 'search', 1 => 'terms', 2 => 'descriptions', 3 => 'urls' )
+ ) );
+ foreach ( $remove as $key ) {
+ $result->removeValue( $key, null );
+ }
}
parent::execute();