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;
* 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 ) {
? $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];
+ }
+ }
}
/**
* @return string
*/
function strencode( $s ) {
- $sQuoted = $this->mysqlRealEscapeString( $s );
-
- if ( $sQuoted === false ) {
- $this->ping();
- $sQuoted = $this->mysqlRealEscapeString( $s );
- }
-
- return $sQuoted;
+ return $this->mysqlRealEscapeString( $s );
}
/**
return strlen( $name ) && $name[0] == '`' && substr( $name, -1, 1 ) == '`';
}
- /**
- * @return bool
- */
- function ping() {
- $ping = $this->mysqlPing();
- if ( $ping ) {
- // Connection was good or lost but reconnected...
- // @note: mysqlnd (php 5.6+) does not support this (PHP bug 52561)
- return true;
- }
-
- // Try a full disconnect/reconnect cycle if ping() failed
- $this->closeConnection();
- $this->mOpened = false;
- $this->mConn = false;
- $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname );
-
- return true;
- }
-
- /**
- * Ping a server connection or reconnect if there is no connection
- *
- * @return bool
- */
- abstract protected function mysqlPing();
-
function getLag() {
if ( $this->getLagDetectionMethod() === 'pt-heartbeat' ) {
return $this->getLagFromPtHeartbeat();
return 0; // already reached this point for sure
}
- // Commit any open transactions
- $this->commit( __METHOD__, 'flush' );
-
// Call doQuery() directly, to avoid opening a transaction if DBO_TRX is set
if ( $this->useGTIDs && $pos->gtids ) {
// Wait on the GTID set (MariaDB only)