Followup r100847, ApiMain now respects $wgShowHostnames
authorJohn Du Hart <johnduhart@users.mediawiki.org>
Wed, 26 Oct 2011 19:39:56 +0000 (19:39 +0000)
committerJohn Du Hart <johnduhart@users.mediawiki.org>
Wed, 26 Oct 2011 19:39:56 +0000 (19:39 +0000)
RELEASE-NOTES-1.19
includes/api/ApiMain.php

index f8bad45..ad88cde 100644 (file)
@@ -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 ===
 
index 11c4b22..549aad6 100644 (file)
@@ -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();