diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:47 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:47 -0400 |
commit | 7e85254903c7c0cb49e381f16b18441ea7b058cc (patch) | |
tree | b22328fcf4c8408fc25a7acb73d1cb1089cd82ac /includes/api | |
parent | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (diff) | |
parent | 1a365e77dfb8825136626202b1df462731b42060 (diff) |
Merge commit '1a365e'
Diffstat (limited to 'includes/api')
-rw-r--r-- | includes/api/ApiBase.php | 2 | ||||
-rw-r--r-- | includes/api/ApiOpenSearch.php | 14 | ||||
-rw-r--r-- | includes/api/ApiQueryImageInfo.php | 5 |
3 files changed, 18 insertions, 3 deletions
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 5a1eb995..6c33da57 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1192,7 +1192,7 @@ abstract class ApiBase extends ContextSource { $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' ); } $token = $user->getOption( 'watchlisttoken' ); - if ( $token == '' || $token != $params['token'] ) { + if ( $token == '' || !hash_equals( $token, $params['token'] ) ) { $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' 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(); diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 94b4bbdb..095e5dda 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -592,7 +592,10 @@ class ApiQueryImageInfo extends ApiQueryBase { $retval = array(); if ( is_array( $metadata ) ) { foreach ( $metadata as $key => $value ) { - $r = array( 'name' => $key ); + $r = array( + 'name' => $key, + ApiResult::META_BC_BOOLS => array( 'value' ), + ); if ( is_array( $value ) ) { $r['value'] = self::processMetaData( $value, $result ); } else { |