X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Flbfactory%2FLBFactory.php;h=64b54e47ae9605d881e11d629b259116d6419444;hp=187527e557688d701c9baa9efac7d93d2798c916;hb=5bad47dbb4519d6a67a2aba468fb513319311c9a;hpb=92f9cb055173058c7c09ea746ba75109fbe0f7ec diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 187527e557..64b54e47ae 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -75,6 +75,11 @@ abstract class LBFactory implements ILBFactory { /** @var callable[] */ protected $replicationWaitCallbacks = []; + /** @var array[] $aliases Map of (table => (dbname, schema, prefix) map) */ + protected $tableAliases = []; + /** @var string[] Map of (index alias => index) */ + protected $indexAliases = []; + /** @var bool Whether this PHP instance is for a CLI script */ protected $cliMode; /** @var string Agent name for query profiling */ @@ -119,7 +124,9 @@ abstract class LBFactory implements ILBFactory { 'ChronologyPositionIndex' => isset( $_GET['cpPosIndex'] ) ? $_GET['cpPosIndex'] : null ]; - $this->cliMode = isset( $conf['cliMode'] ) ? $conf['cliMode'] : PHP_SAPI === 'cli'; + $this->cliMode = isset( $conf['cliMode'] ) + ? $conf['cliMode'] + : ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ); $this->hostname = isset( $conf['hostname'] ) ? $conf['hostname'] : gethostname(); $this->agent = isset( $conf['agent'] ) ? $conf['agent'] : ''; @@ -308,7 +315,7 @@ abstract class LBFactory implements ILBFactory { $opts += [ 'domain' => false, 'cluster' => false, - 'timeout' => 60, + 'timeout' => $this->cliMode ? 60 : 10, 'ifWritesSince' => null ]; @@ -358,7 +365,7 @@ abstract class LBFactory implements ILBFactory { $failed = []; foreach ( $lbs as $i => $lb ) { if ( $masterPositions[$i] ) { - // The DBMS may not support getMasterPos() + // The RDBMS may not support getMasterPos() if ( !$lb->waitForAll( $masterPositions[$i], $opts['timeout'] ) ) { $failed[] = $lb->getServerName( $lb->getWriterIndex() ); } @@ -523,6 +530,17 @@ abstract class LBFactory implements ILBFactory { if ( $this->trxRoundId !== false ) { $lb->beginMasterChanges( $this->trxRoundId ); // set DBO_TRX } + + $lb->setTableAliases( $this->tableAliases ); + $lb->setIndexAliases( $this->indexAliases ); + } + + public function setTableAliases( array $aliases ) { + $this->tableAliases = $aliases; + } + + public function setIndexAliases( array $aliases ) { + $this->indexAliases = $aliases; } public function setDomainPrefix( $prefix ) {