Use __DIR__ instead of dirname( __FILE__ )
[lhc/web/wiklou.git] / maintenance / getSlaveServer.php
index 755659a..ec9ed20 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * This script reports the hostname of a slave server.
+ * Reports the hostname of a slave server.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @file
  * @ingroup Maintenance
  */
 
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
 
+/**
+ * Maintenance script that reports the hostname of a slave server.
+ *
+ * @ingroup Maintenance
+ */
 class GetSlaveServer extends Maintenance {
        public function __construct() {
                parent::__construct();
@@ -32,19 +38,17 @@ class GetSlaveServer extends Maintenance {
                global $wgAllDBsAreLocalhost;
                if ( $wgAllDBsAreLocalhost ) {
                        $host = 'localhost';
+               } elseif ( $this->hasOption( 'group' ) ) {
+                       $db = wfGetDB( DB_SLAVE, $this->getOption( 'group' ) );
+                       $host = $db->getServer();
                } else {
-                       if ( $this->hasOption( 'group' ) ) {
-                               $db = wfGetDB( DB_SLAVE, $this->getOption( 'group' ) );
-                               $host = $db->getServer();
-                       } else {
-                               $lb = wfGetLB();
-                               $i = $lb->getReaderIndex();
-                               $host = $lb->getServerName( $i );
-                       }
+                       $lb = wfGetLB();
+                       $i = $lb->getReaderIndex();
+                       $host = $lb->getServerName( $i );
                }
                $this->output( "$host\n" );
        }
 }
 
 $maintClass = "GetSlaveServer";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );