Merge "Exception is never thrown in the getConnection() method"
[lhc/web/wiklou.git] / includes / libs / rdbms / lbfactory / LBFactory.php
index d213dc9..9ec1ce1 100644 (file)
@@ -95,6 +95,9 @@ abstract class LBFactory implements ILBFactory {
        /** @var string|null */
        private $defaultGroup = null;
 
+       /** @var int|null */
+       protected $maxLag;
+
        const ROUND_CURSORY = 'cursory';
        const ROUND_BEGINNING = 'within-begin';
        const ROUND_COMMITTING = 'within-commit';
@@ -110,6 +113,7 @@ abstract class LBFactory implements ILBFactory {
                        ? DatabaseDomain::newFromId( $conf['localDomain'] )
                        : DatabaseDomain::newUnspecified();
 
+               $this->maxLag = $conf['maxLag'] ?? null;
                if ( isset( $conf['readOnlyReason'] ) && is_string( $conf['readOnlyReason'] ) ) {
                        $this->readOnlyReason = $conf['readOnlyReason'];
                }
@@ -588,6 +592,7 @@ abstract class LBFactory implements ILBFactory {
                        'hostname' => $this->hostname,
                        'cliMode' => $this->cliMode,
                        'agent' => $this->agent,
+                       'maxLag' => $this->maxLag,
                        'defaultGroup' => $this->defaultGroup,
                        'chronologyCallback' => function ( ILoadBalancer $lb ) {
                                // Defer ChronologyProtector construction in case setRequestInfo() ends up
@@ -618,7 +623,15 @@ abstract class LBFactory implements ILBFactory {
                $this->indexAliases = $aliases;
        }
 
+       /**
+        * @param string $prefix
+        * @deprecated Since 1.33
+        */
        public function setDomainPrefix( $prefix ) {
+               $this->setLocalDomainPrefix( $prefix );
+       }
+
+       public function setLocalDomainPrefix( $prefix ) {
                $this->localDomain = new DatabaseDomain(
                        $this->localDomain->getDatabase(),
                        null,
@@ -626,7 +639,17 @@ abstract class LBFactory implements ILBFactory {
                );
 
                $this->forEachLB( function ( ILoadBalancer $lb ) use ( $prefix ) {
-                       $lb->setDomainPrefix( $prefix );
+                       $lb->setLocalDomainPrefix( $prefix );
+               } );
+       }
+
+       public function redefineLocalDomain( $domain ) {
+               $this->closeAll();
+
+               $this->localDomain = DatabaseDomain::newFromId( $domain );
+
+               $this->forEachLB( function ( ILoadBalancer $lb ) {
+                       $lb->redefineLocalDomain( $this->localDomain );
                } );
        }