Merge "rdbms: Use "mixed" type for $profiler field in LoadBalancer"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 25 Oct 2018 21:16:59 +0000 (21:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 25 Oct 2018 21:16:59 +0000 (21:16 +0000)
1  2 
includes/libs/rdbms/loadbalancer/LoadBalancer.php

@@@ -47,7 -47,7 +47,7 @@@ class LoadBalancer implements ILoadBala
        private $srvCache;
        /** @var WANObjectCache */
        private $wanCache;
-       /** @var object|string Class name or object With profileIn/profileOut methods */
+       /** @var mixed Class name or object With profileIn/profileOut methods */
        private $profiler;
        /** @var TransactionProfiler */
        private $trxProfiler;
                        $this->maxLag = $params['maxLag'];
                }
  
 -              if ( isset( $params['loadMonitor'] ) ) {
 -                      $this->loadMonitorConfig = $params['loadMonitor'];
 -              } else {
 -                      $this->loadMonitorConfig = [ 'class' => 'LoadMonitorNull' ];
 -              }
 +              $this->loadMonitorConfig = $params['loadMonitor'] ?? [ 'class' => 'LoadMonitorNull' ];
                $this->loadMonitorConfig += [ 'lagWarnThreshold' => $this->maxLag ];
  
                foreach ( $params['servers'] as $i => $server ) {
                        }
                }
  
 -              if ( isset( $params['srvCache'] ) ) {
 -                      $this->srvCache = $params['srvCache'];
 -              } else {
 -                      $this->srvCache = new EmptyBagOStuff();
 -              }
 -              if ( isset( $params['wanCache'] ) ) {
 -                      $this->wanCache = $params['wanCache'];
 -              } else {
 -                      $this->wanCache = WANObjectCache::newEmpty();
 -              }
 +              $this->srvCache = $params['srvCache'] ?? new EmptyBagOStuff();
 +              $this->wanCache = $params['wanCache'] ?? WANObjectCache::newEmpty();
                $this->profiler = $params['profiler'] ?? null;
 -              if ( isset( $params['trxProfiler'] ) ) {
 -                      $this->trxProfiler = $params['trxProfiler'];
 -              } else {
 -                      $this->trxProfiler = new TransactionProfiler();
 -              }
 +              $this->trxProfiler = $params['trxProfiler'] ?? new TransactionProfiler();
  
                $this->errorLogger = $params['errorLogger'] ?? function ( Exception $e ) {
                        trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
        }
  
        public function getServerName( $i ) {
 -              if ( isset( $this->servers[$i]['hostName'] ) ) {
 -                      $name = $this->servers[$i]['hostName'];
 -              } elseif ( isset( $this->servers[$i]['host'] ) ) {
 -                      $name = $this->servers[$i]['host'];
 -              } else {
 -                      $name = '';
 -              }
 +              $name = $this->servers[$i]['hostName'] ?? $this->servers[$i]['host'] ?? '';
  
                return ( $name != '' ) ? $name : 'localhost';
        }
  
        public function getServerInfo( $i ) {
 -              if ( isset( $this->servers[$i] ) ) {
 -                      return $this->servers[$i];
 -              } else {
 -                      return false;
 -              }
 +              return $this->servers[$i] ?? false;
        }
  
        public function getServerType( $i ) {