From d021e1e965c456b5d75cfaa3c74e94196c319db8 Mon Sep 17 00:00:00 2001 From: John Du Hart Date: Wed, 26 Oct 2011 19:39:56 +0000 Subject: [PATCH] Followup r100847, ApiMain now respects $wgShowHostnames --- RELEASE-NOTES-1.19 | 2 ++ includes/api/ApiMain.php | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index f8bad450b4..ad88cdecbd 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -131,6 +131,8 @@ production. * (bug 26885) Allow show/hide of account blocks, temporary blocks and single IP address blocks for list=blocks. * (bug 30591) Add support to only return keys in ApiAllMessages. +* The API now respects $wgShowHostnames and won't share the hostname in + severedby if it's set to false === Languages updated in 1.19 === diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 11c4b22586..549aad6769 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -486,6 +486,8 @@ class ApiMain extends ApiBase { * @return string */ protected function substituteResultWithError( $e ) { + global $wgShowHostnames; + $result = $this->getResult(); // Printer may not be initialized if the extractRequestParams() fails for the main module if ( !isset ( $this->mPrinter ) ) { @@ -533,8 +535,12 @@ class ApiMain extends ApiBase { if ( !is_null( $requestid ) ) { $result->addValue( null, 'requestid', $requestid ); } - // servedby is especially useful when debugging errors - $result->addValue( null, 'servedby', wfHostName() ); + + if ( $wgShowHostnames ) { + // servedby is especially useful when debugging errors + $result->addValue( null, 'servedby', wfHostName() ); + } + $result->addValue( null, 'error', $errMessage ); return $errMessage['code']; @@ -545,16 +551,20 @@ class ApiMain extends ApiBase { * @return array */ protected function setupExecuteAction() { + global $wgShowHostnames; + // First add the id to the top element $result = $this->getResult(); $requestid = $this->getParameter( 'requestid' ); if ( !is_null( $requestid ) ) { $result->addValue( null, 'requestid', $requestid ); } - // TODO: Isn't there a setting to disable sharing the server hostname? - $servedby = $this->getParameter( 'servedby' ); - if ( $servedby ) { - $result->addValue( null, 'servedby', wfHostName() ); + + if ( $wgShowHostnames ) { + $servedby = $this->getParameter( 'servedby' ); + if ( $servedby ) { + $result->addValue( null, 'servedby', wfHostName() ); + } } $params = $this->extractRequestParams(); -- 2.20.1