summaryrefslogtreecommitdiff
path: root/includes/api
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api')
-rw-r--r--includes/api/ApiBase.php2
-rw-r--r--includes/api/ApiOpenSearch.php14
-rw-r--r--includes/api/ApiQueryImageInfo.php5
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 {