X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fdb%2FDatabaseMysqlBase.php;h=af80d24aef51a7014162f1a140124165ac4014f7;hb=272f45a8a0a682d903bc521c04cbf0f4bc1e099e;hp=fa3756cf2d6b9d26a7cf8df458de14c45c277de7;hpb=da5ecfc384c68d396eae13dbd6160aa7e47e416b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index fa3756cf2d..af80d24aef 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -31,14 +31,21 @@ */ abstract class DatabaseMysqlBase extends Database { /** @var MysqlMasterPos */ - protected $lastKnownSlavePos; - /** @var string Method to detect slave lag */ + protected $lastKnownReplicaPos; + /** @var string Method to detect replica DB lag */ protected $lagDetectionMethod; - /** @var array Method to detect slave lag */ + /** @var array Method to detect replica DB lag */ protected $lagDetectionOptions = []; /** @var bool bool Whether to use GTID methods */ protected $useGTIDs = false; - + /** @var string|null */ + protected $sslKeyPath; + /** @var string|null */ + protected $sslCertPath; + /** @var string|null */ + protected $sslCAPath; + /** @var string[]|null */ + protected $sslCiphers; /** @var string|null */ private $serverVersion = null; @@ -53,6 +60,10 @@ abstract class DatabaseMysqlBase extends Database { * ID of this server's master will be used. Set the "conds" field to * override the query conditions, e.g. ['shard' => 's1']. * - useGTIDs : use GTID methods like MASTER_GTID_WAIT() when possible. + * - sslKeyPath : path to key file [default: null] + * - sslCertPath : path to certificate file [default: null] + * - sslCAPath : parth to certificate authority PEM files [default: null] + * - sslCiphers : array list of allowable ciphers [default: null] * @param array $params */ function __construct( array $params ) { @@ -65,6 +76,12 @@ abstract class DatabaseMysqlBase extends Database { ? $params['lagDetectionOptions'] : []; $this->useGTIDs = !empty( $params['useGTIDs' ] ); + foreach ( [ 'KeyPath', 'CertPath', 'CAPath', 'Ciphers' ] as $name ) { + $var = "ssl{$name}"; + if ( isset( $params[$var] ) ) { + $this->$var = $params[$var]; + } + } } /** @@ -678,7 +695,7 @@ abstract class DatabaseMysqlBase extends Database { $key = $cache->makeGlobalKey( 'mysql', 'master-info', - // Using one key for all cluster slaves is preferable + // Using one key for all cluster replica DBs is preferable $this->getLBInfo( 'clusterMasterHost' ) ?: $this->getServer() ); @@ -754,7 +771,7 @@ abstract class DatabaseMysqlBase extends Database { if ( $this->getLBInfo( 'is static' ) === true ) { return 0; // this is a copy of a read-only dataset with no master DB - } elseif ( $this->lastKnownSlavePos && $this->lastKnownSlavePos->hasReached( $pos ) ) { + } elseif ( $this->lastKnownReplicaPos && $this->lastKnownReplicaPos->hasReached( $pos ) ) { return 0; // already reached this point for sure } @@ -780,16 +797,16 @@ abstract class DatabaseMysqlBase extends Database { if ( $status === null ) { // T126436: jobs programmed to wait on master positions might be referencing binlogs // with an old master hostname. Such calls make MASTER_POS_WAIT() return null. Try - // to detect this and treat the slave as having reached the position; a proper master + // to detect this and treat the replica DB as having reached the position; a proper master // switchover already requires that the new master be caught up before the switch. - $slavePos = $this->getSlavePos(); - if ( $slavePos && !$slavePos->channelsMatch( $pos ) ) { - $this->lastKnownSlavePos = $slavePos; + $replicationPos = $this->getSlavePos(); + if ( $replicationPos && !$replicationPos->channelsMatch( $pos ) ) { + $this->lastKnownReplicaPos = $replicationPos; $status = 0; } } elseif ( $status >= 0 ) { // Remember that this position was reached to save queries next time - $this->lastKnownSlavePos = $pos; + $this->lastKnownReplicaPos = $pos; } return $status; @@ -863,6 +880,14 @@ abstract class DatabaseMysqlBase extends Database { return "FORCE INDEX (" . $this->indexName( $index ) . ")"; } + /** + * @param string $index + * @return string + */ + function ignoreIndexClause( $index ) { + return "IGNORE INDEX (" . $this->indexName( $index ) . ")"; + } + /** * @return string */ @@ -1073,7 +1098,7 @@ abstract class DatabaseMysqlBase extends Database { */ function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = __METHOD__ ) { if ( !$conds ) { - throw new DBUnexpectedError( $this, 'DatabaseBase::deleteJoin() called with empty $conds' ); + throw new DBUnexpectedError( $this, __METHOD__ . ' called with empty $conds' ); } $delTable = $this->tableName( $delTable );