Skip to content

Commit

Permalink
Merge "API: Allow fetching login token from action=query&meta=tokens …
Browse files Browse the repository at this point in the history
…on private wikis"
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Mar 18, 2016
2 parents 036fbcc + 02cc80c commit ecfdb46
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions includes/api/ApiQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,26 @@ private function makeHelpMsgHelper( $group ) {
return implode( "\n", $moduleDescriptions );
}

public function isReadMode() {
// We need to make an exception for ApiQueryTokens so login tokens can
// be fetched on private wikis. Restrict that exception as much as
// possible: no other modules allowed, and no pageset parameters
// either. We do allow the 'rawcontinue' and 'indexpageids' parameters
// since frameworks might add these unconditionally and they can't
// expose anything here.
$params = array_filter(
array_diff_key(
$this->extractRequestParams() + $this->getPageSet()->extractRequestParams(),
[ 'rawcontinue' => 1, 'indexpageids' => 1 ]
)
);
if ( $params === [ 'meta' => [ 'tokens' ] ] ) {
return false;
}

return true;
}

protected function getExamplesMessages() {
return [
'action=query&prop=revisions&meta=siteinfo&' .
Expand Down

0 comments on commit ecfdb46

Please sign in to comment.