(bug 24303) Expose hostname in API results. Show via servedby parameter, added uncond...
authorChad Horohoe <demon@users.mediawiki.org>
Sat, 10 Jul 2010 10:37:39 +0000 (10:37 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Sat, 10 Jul 2010 10:37:39 +0000 (10:37 +0000)
RELEASE-NOTES
includes/api/ApiMain.php
includes/installer/Installer.php
includes/installer/WebInstaller.php

index 4973b34..4ead788 100644 (file)
@@ -264,6 +264,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 24136) unknownerror when adding new section without summary, but forceditsummary
 * (bug 16886) Sister projects box moves down the extract of the first result in IE 7.
 * (bug 22339) Added srwhat=nearmatch to list=search to get a "go" result
+* (bug 24303) Added new &servedby parameter to all actions which adds the hostname
+  that served the request to the result. It is also added unconditionally on error
 
 === Languages updated in 1.17 ===
 
index 260be90..bf6bc89 100644 (file)
@@ -385,6 +385,8 @@ class ApiMain extends ApiBase {
                if ( !is_null( $requestid ) ) {
                        $this->getResult()->addValue( null, 'requestid', $requestid );
                }
+               // servedby is especially useful when debugging errors
+               $this->getResult()->addValue( null, 'servedby', wfHostName() );
                $this->getResult()->addValue( null, 'error', $errMessage );
 
                return $errMessage['code'];
@@ -399,6 +401,10 @@ class ApiMain extends ApiBase {
                if ( !is_null( $requestid ) ) {
                        $this->getResult()->addValue( null, 'requestid', $requestid );
                }
+               $servedby = $this->getParameter( 'servedby' );
+               if( !is_null( $servedby ) ) {
+                       $this->getResult()->addValue( null, 'servedby', wfHostName() );
+               }
 
                $params = $this->extractRequestParams();
 
@@ -591,6 +597,7 @@ class ApiMain extends ApiBase {
                                ApiBase::PARAM_DFLT => 0
                        ),
                        'requestid' => null,
+                       'servedby'  => false,
                );
        }
 
@@ -606,6 +613,7 @@ class ApiMain extends ApiBase {
                        'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached',
                        'maxage' => 'Set the max-age header to this many seconds. Errors are never cached',
                        'requestid' => 'Request ID to distinguish requests. This will just be output back to you',
+                       'servedby' => 'Include the hostname that served the request in the results. Unconditionally shown on error',
                );
        }
 
index 510b8c6..4cfe591 100644 (file)
@@ -298,15 +298,17 @@ abstract class Installer {
         * Under the web subclass, it can already be assumed that PHP 5+ is in use 
         * and that sessions are working.
         */
-       function doEnvironmentChecks() {
+       function doEnvironmentChecks( $beginCB, $endCB ) {
                $this->showMessage( 'config-env-php', phpversion() );
 
                $good = true;
                foreach ( $this->envChecks as $check ) {
+                       call_user_func_array( $beginCB, array( $check ) );
                        $status = $this->$check();
                        if ( $status === false ) {
                                $good = false;
                        }
+                       call_user_func_array( $endCB, array( $check, $status ) );
                }
                $this->setVar( '_Environment', $good );
                if ( $good ) {
index 96d4842..d54602f 100644 (file)
@@ -981,12 +981,20 @@ class WebInstaller_Welcome extends WebInstallerPage {
                }
                $this->parent->output->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
                $status = $this->parent->doEnvironmentChecks();
-               if ( $status ) {
+               if ( $status->isOk() ) {
                        $this->parent->output->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
                        $this->startForm();
                        $this->endForm();
                }
        }
+
+       public function beginEnvCheck( $step ) {
+
+       }
+
+       public function endEnvCheck( $step, $status ) {
+
+       }
 }
 
 class WebInstaller_DBConnect extends WebInstallerPage {