r100858 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100857‎ | r100858 | r100859 >
Date:19:39, 26 October 2011
Author:johnduhart
Status:ok (Comments)
Tags:
Comment:
Followup r100847, ApiMain now respects $wgShowHostnames
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -131,6 +131,8 @@
132132 * (bug 26885) Allow show/hide of account blocks, temporary blocks and single IP
133133 address blocks for list=blocks.
134134 * (bug 30591) Add support to only return keys in ApiAllMessages.
 135+* The API now respects $wgShowHostnames and won't share the hostname in
 136+ severedby if it's set to false
135137
136138 === Languages updated in 1.19 ===
137139
Index: trunk/phase3/includes/api/ApiMain.php
@@ -486,6 +486,8 @@
487487 * @return string
488488 */
489489 protected function substituteResultWithError( $e ) {
 490+ global $wgShowHostnames;
 491+
490492 $result = $this->getResult();
491493 // Printer may not be initialized if the extractRequestParams() fails for the main module
492494 if ( !isset ( $this->mPrinter ) ) {
@@ -533,8 +535,12 @@
534536 if ( !is_null( $requestid ) ) {
535537 $result->addValue( null, 'requestid', $requestid );
536538 }
537 - // servedby is especially useful when debugging errors
538 - $result->addValue( null, 'servedby', wfHostName() );
 539+
 540+ if ( $wgShowHostnames ) {
 541+ // servedby is especially useful when debugging errors
 542+ $result->addValue( null, 'servedby', wfHostName() );
 543+ }
 544+
539545 $result->addValue( null, 'error', $errMessage );
540546
541547 return $errMessage['code'];
@@ -545,16 +551,20 @@
546552 * @return array
547553 */
548554 protected function setupExecuteAction() {
 555+ global $wgShowHostnames;
 556+
549557 // First add the id to the top element
550558 $result = $this->getResult();
551559 $requestid = $this->getParameter( 'requestid' );
552560 if ( !is_null( $requestid ) ) {
553561 $result->addValue( null, 'requestid', $requestid );
554562 }
555 - // TODO: Isn't there a setting to disable sharing the server hostname?
556 - $servedby = $this->getParameter( 'servedby' );
557 - if ( $servedby ) {
558 - $result->addValue( null, 'servedby', wfHostName() );
 563+
 564+ if ( $wgShowHostnames ) {
 565+ $servedby = $this->getParameter( 'servedby' );
 566+ if ( $servedby ) {
 567+ $result->addValue( null, 'servedby', wfHostName() );
 568+ }
559569 }
560570
561571 $params = $this->extractRequestParams();

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100847Small todo note about ApiMainjohnduhart19:04, 26 October 2011

Comments

#Comment by Duplicatebug (talk | contribs)   19:45, 6 November 2011

Please document this on the api help page, because it is good to known, when setting a parameter and you get nothing back, that it is a feature, not a bug ...

Thanks.

Status & tagging log