}
function __destruct() {
- if ( $this->mOpened ) {
+ if ( $this->opened ) {
Wikimedia\suppressWarnings();
$this->close();
Wikimedia\restoreWarnings();
}
$this->close();
- $this->mUser = $user;
- $this->mPassword = $password;
+ $this->user = $user;
+ $this->password = $password;
// changed internal variables functions
// mServer now holds the TNS endpoint
// mDBname is schema name if different from username
if ( !$server ) {
// backward compatibillity (server used to be null and TNS was supplied in dbname)
- $this->mServer = $dbName;
- $this->mDBname = $user;
+ $this->server = $dbName;
+ $this->dbName = $user;
} else {
- $this->mServer = $server;
+ $this->server = $server;
if ( !$dbName ) {
- $this->mDBname = $user;
+ $this->dbName = $user;
} else {
- $this->mDBname = $dbName;
+ $this->dbName = $dbName;
}
}
$this->setFlag( DBO_PERSISTENT );
}
- $session_mode = $this->mFlags & DBO_SYSDBA ? OCI_SYSDBA : OCI_DEFAULT;
+ $session_mode = $this->flags & DBO_SYSDBA ? OCI_SYSDBA : OCI_DEFAULT;
Wikimedia\suppressWarnings();
- if ( $this->mFlags & DBO_PERSISTENT ) {
- $this->mConn = oci_pconnect(
- $this->mUser,
- $this->mPassword,
- $this->mServer,
+ if ( $this->flags & DBO_PERSISTENT ) {
+ $this->conn = oci_pconnect(
+ $this->user,
+ $this->password,
+ $this->server,
$this->defaultCharset,
$session_mode
);
- } elseif ( $this->mFlags & DBO_DEFAULT ) {
- $this->mConn = oci_new_connect(
- $this->mUser,
- $this->mPassword,
- $this->mServer,
+ } elseif ( $this->flags & DBO_DEFAULT ) {
+ $this->conn = oci_new_connect(
+ $this->user,
+ $this->password,
+ $this->server,
$this->defaultCharset,
$session_mode
);
} else {
- $this->mConn = oci_connect(
- $this->mUser,
- $this->mPassword,
- $this->mServer,
+ $this->conn = oci_connect(
+ $this->user,
+ $this->password,
+ $this->server,
$this->defaultCharset,
$session_mode
);
}
Wikimedia\restoreWarnings();
- if ( $this->mUser != $this->mDBname ) {
+ if ( $this->user != $this->dbName ) {
// change current schema in session
- $this->selectDB( $this->mDBname );
+ $this->selectDB( $this->dbName );
}
- if ( !$this->mConn ) {
+ if ( !$this->conn ) {
throw new DBConnectionError( $this, $this->lastError() );
}
- $this->mOpened = true;
+ $this->opened = true;
# removed putenv calls because they interfere with the system globaly
$this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
$this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
$this->doQuery( 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS=\'.,\'' );
- return $this->mConn;
+ return $this->conn;
}
/**
* @return bool
*/
protected function closeConnection() {
- return oci_close( $this->mConn );
+ return oci_close( $this->conn );
}
function execFlags() {
- return $this->mTrxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
+ return $this->trxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
}
protected function doQuery( $sql ) {
Wikimedia\suppressWarnings();
- $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
+ $this->mLastResult = $stmt = oci_parse( $this->conn, $sql );
if ( $stmt === false ) {
- $e = oci_error( $this->mConn );
+ $e = oci_error( $this->conn );
$this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
return false;
}
function lastError() {
- if ( $this->mConn === false ) {
+ if ( $this->conn === false ) {
$e = oci_error();
} else {
- $e = oci_error( $this->mConn );
+ $e = oci_error( $this->conn );
}
return $e['message'];
}
function lastErrno() {
- if ( $this->mConn === false ) {
+ if ( $this->conn === false ) {
$e = oci_error();
} else {
- $e = oci_error( $this->mConn );
+ $e = oci_error( $this->conn );
}
return $e['code'];
}
$sql .= ')';
- $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
+ $this->mLastResult = $stmt = oci_parse( $this->conn, $sql );
if ( $stmt === false ) {
- $e = oci_error( $this->mConn );
+ $e = oci_error( $this->conn );
$this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
return false;
}
} else {
/** @var OCI_Lob[] $lob */
- $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB );
+ $lob[$col] = oci_new_descriptor( $this->conn, OCI_D_LOB );
if ( $lob[$col] === false ) {
$e = oci_error( $stmt );
throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
}
}
- if ( !$this->mTrxLevel ) {
- oci_commit( $this->mConn );
+ if ( !$this->trxLevel ) {
+ oci_commit( $this->conn );
}
return oci_free_statement( $stmt );
FROM all_sequences asq, all_tab_columns atc
WHERE decode(
atc.table_name,
- '{$this->mTablePrefix}MWUSER',
- '{$this->mTablePrefix}USER',
+ '{$this->tablePrefix}MWUSER',
+ '{$this->tablePrefix}USER',
atc.table_name
) || '_' ||
- atc.column_name || '_SEQ' = '{$this->mTablePrefix}' || asq.sequence_name
- AND asq.sequence_owner = upper('{$this->mDBname}')
- AND atc.owner = upper('{$this->mDBname}')" );
+ atc.column_name || '_SEQ' = '{$this->tablePrefix}' || asq.sequence_name
+ AND asq.sequence_owner = upper('{$this->dbName}')
+ AND atc.owner = upper('{$this->dbName}')" );
while ( ( $row = $result->fetchRow() ) !== false ) {
$this->sequenceData[$row[1]] = [
$newName = strtoupper( $newName );
$oldName = strtoupper( $oldName );
- $tabName = substr( $newName, strlen( $this->mTablePrefix ) );
+ $tabName = substr( $newName, strlen( $this->tablePrefix ) );
$oldPrefix = substr( $oldName, 0, strlen( $oldName ) - strlen( $tabName ) );
- $newPrefix = strtoupper( $this->mTablePrefix );
+ $newPrefix = strtoupper( $this->tablePrefix );
return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', " .
"'$oldPrefix', '$newPrefix', $temporary ); END;" );
$listWhere = ' AND table_name LIKE \'' . strtoupper( $prefix ) . '%\'';
}
- $owner = strtoupper( $this->mDBname );
+ $owner = strtoupper( $this->dbName );
$result = $this->doQuery( "SELECT table_name FROM all_tables " .
"WHERE owner='$owner' AND table_name NOT LIKE '%!_IDX\$_' ESCAPE '!' $listWhere" );
);
$row = $rset->fetchRow();
if ( !$row ) {
- return oci_server_version( $this->mConn );
+ return oci_server_version( $this->conn );
}
return $row['version'];
$table = $this->tableName( $table );
$table = strtoupper( $this->removeIdentifierQuotes( $table ) );
$index = strtoupper( $index );
- $owner = strtoupper( $this->mDBname );
+ $owner = strtoupper( $this->dbName );
$sql = "SELECT 1 FROM all_indexes WHERE owner='$owner' AND index_name='{$table}_{$index}'";
$res = $this->doQuery( $sql );
if ( $res ) {
function tableExists( $table, $fname = __METHOD__ ) {
$table = $this->tableName( $table );
$table = $this->addQuotes( strtoupper( $this->removeIdentifierQuotes( $table ) ) );
- $owner = $this->addQuotes( strtoupper( $this->mDBname ) );
+ $owner = $this->addQuotes( strtoupper( $this->dbName ) );
$sql = "SELECT 1 FROM all_tables WHERE owner=$owner AND table_name=$table";
$res = $this->doQuery( $sql );
if ( $res && $res->numRows() > 0 ) {
}
$fieldInfoStmt = oci_parse(
- $this->mConn,
+ $this->conn,
'SELECT * FROM wiki_field_info_full WHERE table_name ' .
$tableWhere . ' and column_name = \'' . $field . '\''
);
}
protected function doBegin( $fname = __METHOD__ ) {
- $this->mTrxLevel = 1;
+ $this->trxLevel = 1;
$this->doQuery( 'SET CONSTRAINTS ALL DEFERRED' );
}
protected function doCommit( $fname = __METHOD__ ) {
- if ( $this->mTrxLevel ) {
- $ret = oci_commit( $this->mConn );
+ if ( $this->trxLevel ) {
+ $ret = oci_commit( $this->conn );
if ( !$ret ) {
throw new DBUnexpectedError( $this, $this->lastError() );
}
- $this->mTrxLevel = 0;
+ $this->trxLevel = 0;
$this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
}
}
protected function doRollback( $fname = __METHOD__ ) {
- if ( $this->mTrxLevel ) {
- oci_rollback( $this->mConn );
- $this->mTrxLevel = 0;
+ if ( $this->trxLevel ) {
+ oci_rollback( $this->conn );
+ $this->trxLevel = 0;
$this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
}
}
}
function selectDB( $db ) {
- $this->mDBname = $db;
- if ( $db == null || $db == $this->mUser ) {
+ $this->dbName = $db;
+ if ( $db == null || $db == $this->user ) {
return true;
}
$sql = 'ALTER SESSION SET CURRENT_SCHEMA=' . strtoupper( $db );
- $stmt = oci_parse( $this->mConn, $sql );
+ $stmt = oci_parse( $this->conn, $sql );
Wikimedia\suppressWarnings();
$success = oci_execute( $stmt );
Wikimedia\restoreWarnings();
$sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
}
- $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
+ $this->mLastResult = $stmt = oci_parse( $this->conn, $sql );
if ( $stmt === false ) {
- $e = oci_error( $this->mConn );
+ $e = oci_error( $this->conn );
$this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
return false;
}
} else {
/** @var OCI_Lob[] $lob */
- $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB );
+ $lob[$col] = oci_new_descriptor( $this->conn, OCI_D_LOB );
if ( $lob[$col] === false ) {
$e = oci_error( $stmt );
throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
}
}
- if ( !$this->mTrxLevel ) {
- oci_commit( $this->mConn );
+ if ( !$this->trxLevel ) {
+ oci_commit( $this->conn );
}
return oci_free_statement( $stmt );
}
function getDBname() {
- return $this->mDBname;
+ return $this->dbName;
}
function getServer() {
- return $this->mServer;
+ return $this->server;
}
public function buildGroupConcatField(
const SMALL_WRITE_ROWS = 100;
/** @var string SQL query */
- protected $mLastQuery = '';
+ protected $lastQuery = '';
/** @var float|bool UNIX timestamp of last write query */
- protected $mLastWriteTime = false;
+ protected $lastWriteTime = false;
/** @var string|bool */
- protected $mPHPError = false;
+ protected $phpError = false;
/** @var string */
- protected $mServer;
+ protected $server;
/** @var string */
- protected $mUser;
+ protected $user;
/** @var string */
- protected $mPassword;
+ protected $password;
/** @var string */
- protected $mDBname;
+ protected $dbName;
/** @var array[] $aliases Map of (table => (dbname, schema, prefix) map) */
protected $tableAliases = [];
/** @var bool Whether this PHP instance is for a CLI script */
protected $errorLogger;
/** @var resource|null Database connection */
- protected $mConn = null;
+ protected $conn = null;
/** @var bool */
- protected $mOpened = false;
+ protected $opened = false;
/** @var array[] List of (callable, method name) */
- protected $mTrxIdleCallbacks = [];
+ protected $trxIdleCallbacks = [];
/** @var array[] List of (callable, method name) */
- protected $mTrxPreCommitCallbacks = [];
+ protected $trxPreCommitCallbacks = [];
/** @var array[] List of (callable, method name) */
- protected $mTrxEndCallbacks = [];
+ protected $trxEndCallbacks = [];
/** @var callable[] Map of (name => callable) */
- protected $mTrxRecurringCallbacks = [];
+ protected $trxRecurringCallbacks = [];
/** @var bool Whether to suppress triggering of transaction end callbacks */
- protected $mTrxEndCallbacksSuppressed = false;
+ protected $trxEndCallbacksSuppressed = false;
/** @var string */
- protected $mTablePrefix = '';
+ protected $tablePrefix = '';
/** @var string */
- protected $mSchema = '';
+ protected $schema = '';
/** @var int */
- protected $mFlags;
+ protected $flags;
/** @var array */
- protected $mLBInfo = [];
- /** @var bool|null */
- protected $mDefaultBigSelects = null;
+ protected $lbInfo = [];
/** @var array|bool */
- protected $mSchemaVars = false;
+ protected $schemaVars = false;
/** @var array */
- protected $mSessionVars = [];
+ protected $sessionVars = [];
/** @var array|null */
protected $preparedArgs;
/** @var string|bool|null Stashed value of html_errors INI setting */
*
* @var int
*/
- protected $mTrxLevel = 0;
+ protected $trxLevel = 0;
/**
* Either a short hexidecimal string if a transaction is active or ""
*
* @var string
- * @see Database::mTrxLevel
+ * @see Database::trxLevel
*/
- protected $mTrxShortId = '';
+ protected $trxShortId = '';
/**
* The UNIX time that the transaction started. Callers can assume that if
* snapshot isolation is used, then the data is *at least* up to date to that
* point (possibly more up-to-date since the first SELECT defines the snapshot).
*
* @var float|null
- * @see Database::mTrxLevel
+ * @see Database::trxLevel
*/
- private $mTrxTimestamp = null;
+ private $trxTimestamp = null;
/** @var float Lag estimate at the time of BEGIN */
- private $mTrxReplicaLag = null;
+ private $trxReplicaLag = null;
/**
* Remembers the function name given for starting the most recent transaction via begin().
* Used to provide additional context for error reporting.
*
* @var string
- * @see Database::mTrxLevel
+ * @see Database::trxLevel
*/
- private $mTrxFname = null;
+ private $trxFname = null;
/**
* Record if possible write queries were done in the last transaction started
*
* @var bool
- * @see Database::mTrxLevel
+ * @see Database::trxLevel
*/
- private $mTrxDoneWrites = false;
+ private $trxDoneWrites = false;
/**
* Record if the current transaction was started implicitly due to DBO_TRX being set.
*
* @var bool
- * @see Database::mTrxLevel
+ * @see Database::trxLevel
*/
- private $mTrxAutomatic = false;
+ private $trxAutomatic = false;
/**
* Array of levels of atomicity within transactions
*
* @var array
*/
- private $mTrxAtomicLevels = [];
+ private $trxAtomicLevels = [];
/**
* Record if the current transaction was started implicitly by Database::startAtomic
*
* @var bool
*/
- private $mTrxAutomaticAtomic = false;
+ private $trxAutomaticAtomic = false;
/**
* Track the write query callers of the current transaction
*
* @var string[]
*/
- private $mTrxWriteCallers = [];
+ private $trxWriteCallers = [];
/**
* @var float Seconds spent in write queries for the current transaction
*/
- private $mTrxWriteDuration = 0.0;
+ private $trxWriteDuration = 0.0;
/**
* @var int Number of write queries for the current transaction
*/
- private $mTrxWriteQueryCount = 0;
+ private $trxWriteQueryCount = 0;
/**
* @var int Number of rows affected by write queries for the current transaction
*/
- private $mTrxWriteAffectedRows = 0;
+ private $trxWriteAffectedRows = 0;
/**
- * @var float Like mTrxWriteQueryCount but excludes lock-bound, easy to replicate, queries
+ * @var float Like trxWriteQueryCount but excludes lock-bound, easy to replicate, queries
*/
- private $mTrxWriteAdjDuration = 0.0;
+ private $trxWriteAdjDuration = 0.0;
/**
- * @var int Number of write queries counted in mTrxWriteAdjDuration
+ * @var int Number of write queries counted in trxWriteAdjDuration
*/
- private $mTrxWriteAdjQueryCount = 0;
+ private $trxWriteAdjQueryCount = 0;
/**
* @var float RTT time estimate
*/
- private $mRTTEstimate = 0.0;
+ private $rttEstimate = 0.0;
/** @var array Map of (name => 1) for locks obtained via lock() */
- private $mNamedLocksHeld = [];
+ private $namedLocksHeld = [];
/** @var array Map of (table name => 1) for TEMPORARY tables */
- protected $mSessionTempTables = [];
+ protected $sessionTempTables = [];
/** @var IDatabase|null Lazy handle to the master DB this server replicates from */
private $lazyMasterHandle;
/** @var float UNIX timestamp */
protected $lastPing = 0.0;
- /** @var int[] Prior mFlags values */
+ /** @var int[] Prior flags member variable values */
private $priorFlags = [];
/** @var object|string Class name or object With profileIn/profileOut methods */
$password = $params['password'];
$dbName = $params['dbname'];
- $this->mSchema = $params['schema'];
- $this->mTablePrefix = $params['tablePrefix'];
+ $this->schema = $params['schema'];
+ $this->tablePrefix = $params['tablePrefix'];
$this->cliMode = $params['cliMode'];
// Agent name is added to SQL queries in a comment, so make sure it can't break out
$this->agent = str_replace( '/', '-', $params['agent'] );
- $this->mFlags = $params['flags'];
- if ( $this->mFlags & self::DBO_DEFAULT ) {
+ $this->flags = $params['flags'];
+ if ( $this->flags & self::DBO_DEFAULT ) {
if ( $this->cliMode ) {
- $this->mFlags &= ~self::DBO_TRX;
+ $this->flags &= ~self::DBO_TRX;
} else {
- $this->mFlags |= self::DBO_TRX;
+ $this->flags |= self::DBO_TRX;
}
}
- $this->mSessionVars = $params['variables'];
+ $this->sessionVars = $params['variables'];
$this->srvCache = isset( $params['srvCache'] )
? $params['srvCache']
}
// Set the domain object after open() sets the relevant fields
- if ( $this->mDBname != '' ) {
+ if ( $this->dbName != '' ) {
// Domains with server scope but a table prefix are not used by IDatabase classes
- $this->currentDomain = new DatabaseDomain( $this->mDBname, null, $this->mTablePrefix );
+ $this->currentDomain = new DatabaseDomain( $this->dbName, null, $this->tablePrefix );
}
}
if ( $ignoreErrors !== null ) {
// setFlag()/clearFlag() do not allow DBO_IGNORE changes for sanity
if ( $ignoreErrors ) {
- $this->mFlags |= self::DBO_IGNORE;
+ $this->flags |= self::DBO_IGNORE;
} else {
- $this->mFlags &= ~self::DBO_IGNORE;
+ $this->flags &= ~self::DBO_IGNORE;
}
}
}
public function trxLevel() {
- return $this->mTrxLevel;
+ return $this->trxLevel;
}
public function trxTimestamp() {
- return $this->mTrxLevel ? $this->mTrxTimestamp : null;
+ return $this->trxLevel ? $this->trxTimestamp : null;
}
public function tablePrefix( $prefix = null ) {
- $old = $this->mTablePrefix;
+ $old = $this->tablePrefix;
if ( $prefix !== null ) {
- $this->mTablePrefix = $prefix;
- $this->currentDomain = ( $this->mDBname != '' )
- ? new DatabaseDomain( $this->mDBname, null, $this->mTablePrefix )
+ $this->tablePrefix = $prefix;
+ $this->currentDomain = ( $this->dbName != '' )
+ ? new DatabaseDomain( $this->dbName, null, $this->tablePrefix )
: DatabaseDomain::newUnspecified();
}
}
public function dbSchema( $schema = null ) {
- $old = $this->mSchema;
+ $old = $this->schema;
if ( $schema !== null ) {
- $this->mSchema = $schema;
+ $this->schema = $schema;
}
return $old;
public function getLBInfo( $name = null ) {
if ( is_null( $name ) ) {
- return $this->mLBInfo;
+ return $this->lbInfo;
} else {
- if ( array_key_exists( $name, $this->mLBInfo ) ) {
- return $this->mLBInfo[$name];
+ if ( array_key_exists( $name, $this->lbInfo ) ) {
+ return $this->lbInfo[$name];
} else {
return null;
}
public function setLBInfo( $name, $value = null ) {
if ( is_null( $value ) ) {
- $this->mLBInfo = $name;
+ $this->lbInfo = $name;
} else {
- $this->mLBInfo[$name] = $value;
+ $this->lbInfo[$name] = $value;
}
}
}
public function lastQuery() {
- return $this->mLastQuery;
+ return $this->lastQuery;
}
public function doneWrites() {
- return (bool)$this->mLastWriteTime;
+ return (bool)$this->lastWriteTime;
}
public function lastDoneWrites() {
- return $this->mLastWriteTime ?: false;
+ return $this->lastWriteTime ?: false;
}
public function writesPending() {
- return $this->mTrxLevel && $this->mTrxDoneWrites;
+ return $this->trxLevel && $this->trxDoneWrites;
}
public function writesOrCallbacksPending() {
- return $this->mTrxLevel && (
- $this->mTrxDoneWrites || $this->mTrxIdleCallbacks || $this->mTrxPreCommitCallbacks
+ return $this->trxLevel && (
+ $this->trxDoneWrites || $this->trxIdleCallbacks || $this->trxPreCommitCallbacks
);
}
public function pendingWriteQueryDuration( $type = self::ESTIMATE_TOTAL ) {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
return false;
- } elseif ( !$this->mTrxDoneWrites ) {
+ } elseif ( !$this->trxDoneWrites ) {
return 0.0;
}
switch ( $type ) {
case self::ESTIMATE_DB_APPLY:
$this->ping( $rtt );
- $rttAdjTotal = $this->mTrxWriteAdjQueryCount * $rtt;
- $applyTime = max( $this->mTrxWriteAdjDuration - $rttAdjTotal, 0 );
+ $rttAdjTotal = $this->trxWriteAdjQueryCount * $rtt;
+ $applyTime = max( $this->trxWriteAdjDuration - $rttAdjTotal, 0 );
// For omitted queries, make them count as something at least
- $omitted = $this->mTrxWriteQueryCount - $this->mTrxWriteAdjQueryCount;
+ $omitted = $this->trxWriteQueryCount - $this->trxWriteAdjQueryCount;
$applyTime += self::TINY_WRITE_SEC * $omitted;
return $applyTime;
default: // everything
- return $this->mTrxWriteDuration;
+ return $this->trxWriteDuration;
}
}
public function pendingWriteCallers() {
- return $this->mTrxLevel ? $this->mTrxWriteCallers : [];
+ return $this->trxLevel ? $this->trxWriteCallers : [];
}
public function pendingWriteRowsAffected() {
- return $this->mTrxWriteAffectedRows;
+ return $this->trxWriteAffectedRows;
}
/**
* @return array
*/
protected function pendingWriteAndCallbackCallers() {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
return [];
}
- $fnames = $this->mTrxWriteCallers;
+ $fnames = $this->trxWriteCallers;
foreach ( [
- $this->mTrxIdleCallbacks,
- $this->mTrxPreCommitCallbacks,
- $this->mTrxEndCallbacks
+ $this->trxIdleCallbacks,
+ $this->trxPreCommitCallbacks,
+ $this->trxEndCallbacks
] as $callbacks ) {
foreach ( $callbacks as $callback ) {
$fnames[] = $callback[1];
}
public function isOpen() {
- return $this->mOpened;
+ return $this->opened;
}
public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
}
if ( $remember === self::REMEMBER_PRIOR ) {
- array_push( $this->priorFlags, $this->mFlags );
+ array_push( $this->priorFlags, $this->flags );
}
- $this->mFlags |= $flag;
+ $this->flags |= $flag;
}
public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
}
if ( $remember === self::REMEMBER_PRIOR ) {
- array_push( $this->priorFlags, $this->mFlags );
+ array_push( $this->priorFlags, $this->flags );
}
- $this->mFlags &= ~$flag;
+ $this->flags &= ~$flag;
}
public function restoreFlags( $state = self::RESTORE_PRIOR ) {
}
if ( $state === self::RESTORE_INITIAL ) {
- $this->mFlags = reset( $this->priorFlags );
+ $this->flags = reset( $this->priorFlags );
$this->priorFlags = [];
} else {
- $this->mFlags = array_pop( $this->priorFlags );
+ $this->flags = array_pop( $this->priorFlags );
}
}
public function getFlag( $flag ) {
- return !!( $this->mFlags & $flag );
+ return !!( $this->flags & $flag );
}
/**
* Set a custom error handler for logging errors during database connection
*/
protected function installErrorHandler() {
- $this->mPHPError = false;
+ $this->phpError = false;
$this->htmlErrors = ini_set( 'html_errors', '0' );
set_error_handler( [ $this, 'connectionErrorLogger' ] );
}
* @return string|bool Last PHP error for this DB (typically connection errors)
*/
protected function getLastPHPError() {
- if ( $this->mPHPError ) {
- $error = preg_replace( '!\[<a.*</a>\]!', '', $this->mPHPError );
+ if ( $this->phpError ) {
+ $error = preg_replace( '!\[<a.*</a>\]!', '', $this->phpError );
$error = preg_replace( '!^.*?:\s?(.*)$!', '$1', $error );
return $error;
* @param string $errstr
*/
public function connectionErrorLogger( $errno, $errstr ) {
- $this->mPHPError = $errstr;
+ $this->phpError = $errstr;
}
/**
protected function getLogContext( array $extras = [] ) {
return array_merge(
[
- 'db_server' => $this->mServer,
- 'db_name' => $this->mDBname,
- 'db_user' => $this->mUser,
+ 'db_server' => $this->server,
+ 'db_name' => $this->dbName,
+ 'db_user' => $this->user,
],
$extras
);
}
public function close() {
- if ( $this->mConn ) {
+ if ( $this->conn ) {
if ( $this->trxLevel() ) {
$this->commit( __METHOD__, self::FLUSHING_INTERNAL );
}
$closed = $this->closeConnection();
- $this->mConn = false;
+ $this->conn = false;
} elseif (
- $this->mTrxIdleCallbacks ||
- $this->mTrxPreCommitCallbacks ||
- $this->mTrxEndCallbacks
+ $this->trxIdleCallbacks ||
+ $this->trxPreCommitCallbacks ||
+ $this->trxEndCallbacks
) { // sanity
throw new RuntimeException( "Transaction callbacks still pending." );
} else {
$closed = true;
}
- $this->mOpened = false;
+ $this->opened = false;
return $closed;
}
$sql,
$matches
) ) {
- $this->mSessionTempTables[$matches[1]] = 1;
+ $this->sessionTempTables[$matches[1]] = 1;
return true;
} elseif ( preg_match(
$sql,
$matches
) ) {
- $isTemp = isset( $this->mSessionTempTables[$matches[1]] );
- unset( $this->mSessionTempTables[$matches[1]] );
+ $isTemp = isset( $this->sessionTempTables[$matches[1]] );
+ unset( $this->sessionTempTables[$matches[1]] );
return $isTemp;
} elseif ( preg_match(
$sql,
$matches
) ) {
- return isset( $this->mSessionTempTables[$matches[1]] );
+ return isset( $this->sessionTempTables[$matches[1]] );
} elseif ( preg_match(
'/^(?:INSERT\s+(?:\w+\s+)?INTO|UPDATE|DELETE\s+FROM)\s+[`"\']?(\w+)[`"\']?/i',
$sql,
$matches
) ) {
- return isset( $this->mSessionTempTables[$matches[1]] );
+ return isset( $this->sessionTempTables[$matches[1]] );
}
return false;
public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
$priorWritesPending = $this->writesOrCallbacksPending();
- $this->mLastQuery = $sql;
+ $this->lastQuery = $sql;
$isWrite = $this->isWriteQuery( $sql );
if ( $isWrite ) {
throw new DBReadOnlyError( $this, "Database is read-only: $reason" );
}
# Set a flag indicating that writes have been done
- $this->mLastWriteTime = microtime( true );
+ $this->lastWriteTime = microtime( true );
}
# Add trace comment to the begin of the sql string, right after the operator.
$commentedSql = preg_replace( '/\s|$/', " /* $fname {$this->agent} */ ", $sql, 1 );
# Start implicit transactions that wrap the request if DBO_TRX is enabled
- if ( !$this->mTrxLevel && $this->getFlag( self::DBO_TRX )
+ if ( !$this->trxLevel && $this->getFlag( self::DBO_TRX )
&& $this->isTransactableQuery( $sql )
) {
$this->begin( __METHOD__ . " ($fname)", self::TRANSACTION_INTERNAL );
- $this->mTrxAutomatic = true;
+ $this->trxAutomatic = true;
}
# Keep track of whether the transaction has write queries pending
- if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $isWrite ) {
- $this->mTrxDoneWrites = true;
+ if ( $this->trxLevel && !$this->trxDoneWrites && $isWrite ) {
+ $this->trxDoneWrites = true;
$this->trxProfiler->transactionWritingIn(
- $this->mServer, $this->mDBname, $this->mTrxShortId );
+ $this->server, $this->dbName, $this->trxShortId );
}
if ( $this->getFlag( self::DBO_DEBUG ) ) {
- $this->queryLogger->debug( "{$this->mDBname} {$commentedSql}" );
+ $this->queryLogger->debug( "{$this->dbName} {$commentedSql}" );
}
# Avoid fatals if close() was called
}
# Include query transaction state
- $queryProf .= $this->mTrxShortId ? " [TRX#{$this->mTrxShortId}]" : "";
+ $queryProf .= $this->trxShortId ? " [TRX#{$this->trxShortId}]" : "";
$startTime = microtime( true );
if ( $this->profiler ) {
if ( $ret !== false ) {
$this->lastPing = $startTime;
- if ( $isWrite && $this->mTrxLevel ) {
+ if ( $isWrite && $this->trxLevel ) {
$this->updateTrxWriteQueryTime( $sql, $queryRuntime, $this->affectedRows() );
- $this->mTrxWriteCallers[] = $fname;
+ $this->trxWriteCallers[] = $fname;
}
}
if ( $sql === self::PING_QUERY ) {
- $this->mRTTEstimate = $queryRuntime;
+ $this->rttEstimate = $queryRuntime;
}
$this->trxProfiler->recordQueryCompletion(
}
}
- $this->mTrxWriteDuration += $runtime;
- $this->mTrxWriteQueryCount += 1;
- $this->mTrxWriteAffectedRows += $affected;
+ $this->trxWriteDuration += $runtime;
+ $this->trxWriteQueryCount += 1;
+ $this->trxWriteAffectedRows += $affected;
if ( $indicativeOfReplicaRuntime ) {
- $this->mTrxWriteAdjDuration += $runtime;
- $this->mTrxWriteAdjQueryCount += 1;
+ $this->trxWriteAdjDuration += $runtime;
+ $this->trxWriteAdjQueryCount += 1;
}
}
# Dropped connections also mean that named locks are automatically released.
# Only allow error suppression in autocommit mode or when the lost transaction
# didn't matter anyway (aside from DBO_TRX snapshot loss).
- if ( $this->mNamedLocksHeld ) {
+ if ( $this->namedLocksHeld ) {
return false; // possible critical section violation
} elseif ( $sql === 'COMMIT' ) {
return !$priorWritesPending; // nothing written anyway? (T127428)
* @return null|Exception
*/
private function handleSessionLoss() {
- $this->mTrxLevel = 0;
- $this->mTrxIdleCallbacks = []; // T67263
- $this->mTrxPreCommitCallbacks = []; // T67263
- $this->mSessionTempTables = [];
- $this->mNamedLocksHeld = [];
+ $this->trxLevel = 0;
+ $this->trxIdleCallbacks = []; // T67263
+ $this->trxPreCommitCallbacks = []; // T67263
+ $this->sessionTempTables = [];
+ $this->namedLocksHeld = [];
try {
- // Handle callbacks in mTrxEndCallbacks
+ // Handle callbacks in trxEndCallbacks
$this->runOnTransactionIdleCallbacks( self::TRIGGER_ROLLBACK );
$this->runTransactionListenerCallbacks( self::TRIGGER_ROLLBACK );
return null;
public function tableExists( $table, $fname = __METHOD__ ) {
$tableRaw = $this->tableName( $table, 'raw' );
- if ( isset( $this->mSessionTempTables[$tableRaw] ) ) {
+ if ( isset( $this->sessionTempTables[$tableRaw] ) ) {
return true; // already known to exist
}
# Stub. Shouldn't cause serious problems if it's not overridden, but
# if your database engine supports a concept similar to MySQL's
# databases you may as well.
- $this->mDBname = $db;
+ $this->dbName = $db;
return true;
}
public function getDBname() {
- return $this->mDBname;
+ return $this->dbName;
}
public function getServer() {
- return $this->mServer;
+ return $this->server;
}
public function tableName( $name, $format = 'quoted' ) {
$database = $this->tableAliases[$table]['dbname'];
$schema = is_string( $this->tableAliases[$table]['schema'] )
? $this->tableAliases[$table]['schema']
- : $this->mSchema;
+ : $this->schema;
$prefix = is_string( $this->tableAliases[$table]['prefix'] )
? $this->tableAliases[$table]['prefix']
- : $this->mTablePrefix;
+ : $this->tablePrefix;
} else {
$database = '';
- $schema = $this->mSchema; # Default schema
- $prefix = $this->mTablePrefix; # Default prefix
+ $schema = $this->schema; # Default schema
+ $prefix = $this->tablePrefix; # Default prefix
}
}
}
$affectedRowCount = 0;
- $useTrx = !$this->mTrxLevel;
+ $useTrx = !$this->trxLevel;
if ( $useTrx ) {
$this->begin( $fname, self::TRANSACTION_INTERNAL );
}
}
final public function onTransactionResolution( callable $callback, $fname = __METHOD__ ) {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
throw new DBUnexpectedError( $this, "No transaction is active." );
}
- $this->mTrxEndCallbacks[] = [ $callback, $fname ];
+ $this->trxEndCallbacks[] = [ $callback, $fname ];
}
final public function onTransactionIdle( callable $callback, $fname = __METHOD__ ) {
- $this->mTrxIdleCallbacks[] = [ $callback, $fname ];
- if ( !$this->mTrxLevel ) {
+ $this->trxIdleCallbacks[] = [ $callback, $fname ];
+ if ( !$this->trxLevel ) {
$this->runOnTransactionIdleCallbacks( self::TRIGGER_IDLE );
}
}
final public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
- if ( $this->mTrxLevel || $this->getFlag( self::DBO_TRX ) ) {
+ if ( $this->trxLevel || $this->getFlag( self::DBO_TRX ) ) {
// As long as DBO_TRX is set, writes will accumulate until the load balancer issues
// an implicit commit of all peer databases. This is true even if a transaction has
// not yet been triggered by writes; make sure $callback runs *after* any such writes.
- $this->mTrxPreCommitCallbacks[] = [ $callback, $fname ];
+ $this->trxPreCommitCallbacks[] = [ $callback, $fname ];
} else {
// No transaction is active nor will start implicitly, so make one for this callback
$this->startAtomic( __METHOD__ );
final public function setTransactionListener( $name, callable $callback = null ) {
if ( $callback ) {
- $this->mTrxRecurringCallbacks[$name] = $callback;
+ $this->trxRecurringCallbacks[$name] = $callback;
} else {
- unset( $this->mTrxRecurringCallbacks[$name] );
+ unset( $this->trxRecurringCallbacks[$name] );
}
}
* @since 1.28
*/
final public function setTrxEndCallbackSuppression( $suppress ) {
- $this->mTrxEndCallbacksSuppressed = $suppress;
+ $this->trxEndCallbacksSuppressed = $suppress;
}
/**
* @throws Exception
*/
public function runOnTransactionIdleCallbacks( $trigger ) {
- if ( $this->mTrxEndCallbacksSuppressed ) {
+ if ( $this->trxEndCallbacksSuppressed ) {
return;
}
$e = null; // first exception
do { // callbacks may add callbacks :)
$callbacks = array_merge(
- $this->mTrxIdleCallbacks,
- $this->mTrxEndCallbacks // include "transaction resolution" callbacks
+ $this->trxIdleCallbacks,
+ $this->trxEndCallbacks // include "transaction resolution" callbacks
);
- $this->mTrxIdleCallbacks = []; // consumed (and recursion guard)
- $this->mTrxEndCallbacks = []; // consumed (recursion guard)
+ $this->trxIdleCallbacks = []; // consumed (and recursion guard)
+ $this->trxEndCallbacks = []; // consumed (recursion guard)
foreach ( $callbacks as $callback ) {
try {
list( $phpCallback ) = $callback;
}
}
}
- } while ( count( $this->mTrxIdleCallbacks ) );
+ } while ( count( $this->trxIdleCallbacks ) );
if ( $e instanceof Exception ) {
throw $e; // re-throw any first exception
public function runOnTransactionPreCommitCallbacks() {
$e = null; // first exception
do { // callbacks may add callbacks :)
- $callbacks = $this->mTrxPreCommitCallbacks;
- $this->mTrxPreCommitCallbacks = []; // consumed (and recursion guard)
+ $callbacks = $this->trxPreCommitCallbacks;
+ $this->trxPreCommitCallbacks = []; // consumed (and recursion guard)
foreach ( $callbacks as $callback ) {
try {
list( $phpCallback ) = $callback;
$e = $e ?: $ex;
}
}
- } while ( count( $this->mTrxPreCommitCallbacks ) );
+ } while ( count( $this->trxPreCommitCallbacks ) );
if ( $e instanceof Exception ) {
throw $e; // re-throw any first exception
* @since 1.20
*/
public function runTransactionListenerCallbacks( $trigger ) {
- if ( $this->mTrxEndCallbacksSuppressed ) {
+ if ( $this->trxEndCallbacksSuppressed ) {
return;
}
/** @var Exception $e */
$e = null; // first exception
- foreach ( $this->mTrxRecurringCallbacks as $phpCallback ) {
+ foreach ( $this->trxRecurringCallbacks as $phpCallback ) {
try {
$phpCallback( $trigger, $this );
} catch ( Exception $ex ) {
}
final public function startAtomic( $fname = __METHOD__ ) {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
$this->begin( $fname, self::TRANSACTION_INTERNAL );
// If DBO_TRX is set, a series of startAtomic/endAtomic pairs will result
// in all changes being in one transaction to keep requests transactional.
if ( !$this->getFlag( self::DBO_TRX ) ) {
- $this->mTrxAutomaticAtomic = true;
+ $this->trxAutomaticAtomic = true;
}
}
- $this->mTrxAtomicLevels[] = $fname;
+ $this->trxAtomicLevels[] = $fname;
}
final public function endAtomic( $fname = __METHOD__ ) {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
throw new DBUnexpectedError( $this, "No atomic transaction is open (got $fname)." );
}
- if ( !$this->mTrxAtomicLevels ||
- array_pop( $this->mTrxAtomicLevels ) !== $fname
+ if ( !$this->trxAtomicLevels ||
+ array_pop( $this->trxAtomicLevels ) !== $fname
) {
throw new DBUnexpectedError( $this, "Invalid atomic section ended (got $fname)." );
}
- if ( !$this->mTrxAtomicLevels && $this->mTrxAutomaticAtomic ) {
+ if ( !$this->trxAtomicLevels && $this->trxAutomaticAtomic ) {
$this->commit( $fname, self::FLUSHING_INTERNAL );
}
}
final public function begin( $fname = __METHOD__, $mode = self::TRANSACTION_EXPLICIT ) {
// Protect against mismatched atomic section, transaction nesting, and snapshot loss
- if ( $this->mTrxLevel ) {
- if ( $this->mTrxAtomicLevels ) {
- $levels = implode( ', ', $this->mTrxAtomicLevels );
+ if ( $this->trxLevel ) {
+ if ( $this->trxAtomicLevels ) {
+ $levels = implode( ', ', $this->trxAtomicLevels );
$msg = "$fname: Got explicit BEGIN while atomic section(s) $levels are open.";
throw new DBUnexpectedError( $this, $msg );
- } elseif ( !$this->mTrxAutomatic ) {
- $msg = "$fname: Explicit transaction already active (from {$this->mTrxFname}).";
+ } elseif ( !$this->trxAutomatic ) {
+ $msg = "$fname: Explicit transaction already active (from {$this->trxFname}).";
throw new DBUnexpectedError( $this, $msg );
} else {
// @TODO: make this an exception at some point
- $msg = "$fname: Implicit transaction already active (from {$this->mTrxFname}).";
+ $msg = "$fname: Implicit transaction already active (from {$this->trxFname}).";
$this->queryLogger->error( $msg );
return; // join the main transaction set
}
$this->assertOpen();
$this->doBegin( $fname );
- $this->mTrxTimestamp = microtime( true );
- $this->mTrxFname = $fname;
- $this->mTrxDoneWrites = false;
- $this->mTrxAutomaticAtomic = false;
- $this->mTrxAtomicLevels = [];
- $this->mTrxShortId = sprintf( '%06x', mt_rand( 0, 0xffffff ) );
- $this->mTrxWriteDuration = 0.0;
- $this->mTrxWriteQueryCount = 0;
- $this->mTrxWriteAffectedRows = 0;
- $this->mTrxWriteAdjDuration = 0.0;
- $this->mTrxWriteAdjQueryCount = 0;
- $this->mTrxWriteCallers = [];
+ $this->trxTimestamp = microtime( true );
+ $this->trxFname = $fname;
+ $this->trxDoneWrites = false;
+ $this->trxAutomaticAtomic = false;
+ $this->trxAtomicLevels = [];
+ $this->trxShortId = sprintf( '%06x', mt_rand( 0, 0xffffff ) );
+ $this->trxWriteDuration = 0.0;
+ $this->trxWriteQueryCount = 0;
+ $this->trxWriteAffectedRows = 0;
+ $this->trxWriteAdjDuration = 0.0;
+ $this->trxWriteAdjQueryCount = 0;
+ $this->trxWriteCallers = [];
// First SELECT after BEGIN will establish the snapshot in REPEATABLE-READ.
// Get an estimate of the replica DB lag before then, treating estimate staleness
// as lag itself just to be safe
$status = $this->getApproximateLagStatus();
- $this->mTrxReplicaLag = $status['lag'] + ( microtime( true ) - $status['since'] );
+ $this->trxReplicaLag = $status['lag'] + ( microtime( true ) - $status['since'] );
// T147697: make explicitTrxActive() return true until begin() finishes. This way, no
// caller will think its OK to muck around with the transaction just because startAtomic()
- // has not yet completed (e.g. setting mTrxAtomicLevels).
- $this->mTrxAutomatic = ( $mode === self::TRANSACTION_INTERNAL );
+ // has not yet completed (e.g. setting trxAtomicLevels).
+ $this->trxAutomatic = ( $mode === self::TRANSACTION_INTERNAL );
}
/**
*/
protected function doBegin( $fname ) {
$this->query( 'BEGIN', $fname );
- $this->mTrxLevel = 1;
+ $this->trxLevel = 1;
}
final public function commit( $fname = __METHOD__, $flush = '' ) {
- if ( $this->mTrxLevel && $this->mTrxAtomicLevels ) {
+ if ( $this->trxLevel && $this->trxAtomicLevels ) {
// There are still atomic sections open. This cannot be ignored
- $levels = implode( ', ', $this->mTrxAtomicLevels );
+ $levels = implode( ', ', $this->trxAtomicLevels );
throw new DBUnexpectedError(
$this,
"$fname: Got COMMIT while atomic sections $levels are still open."
}
if ( $flush === self::FLUSHING_INTERNAL || $flush === self::FLUSHING_ALL_PEERS ) {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
return; // nothing to do
- } elseif ( !$this->mTrxAutomatic ) {
+ } elseif ( !$this->trxAutomatic ) {
throw new DBUnexpectedError(
$this,
"$fname: Flushing an explicit transaction, getting out of sync."
);
}
} else {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
$this->queryLogger->error(
"$fname: No transaction to commit, something got out of sync." );
return; // nothing to do
- } elseif ( $this->mTrxAutomatic ) {
+ } elseif ( $this->trxAutomatic ) {
// @TODO: make this an exception at some point
$msg = "$fname: Explicit commit of implicit transaction.";
$this->queryLogger->error( $msg );
$this->runOnTransactionPreCommitCallbacks();
$writeTime = $this->pendingWriteQueryDuration( self::ESTIMATE_DB_APPLY );
$this->doCommit( $fname );
- if ( $this->mTrxDoneWrites ) {
- $this->mLastWriteTime = microtime( true );
+ if ( $this->trxDoneWrites ) {
+ $this->lastWriteTime = microtime( true );
$this->trxProfiler->transactionWritingOut(
- $this->mServer,
- $this->mDBname,
- $this->mTrxShortId,
+ $this->server,
+ $this->dbName,
+ $this->trxShortId,
$writeTime,
- $this->mTrxWriteAffectedRows
+ $this->trxWriteAffectedRows
);
}
* @param string $fname
*/
protected function doCommit( $fname ) {
- if ( $this->mTrxLevel ) {
+ if ( $this->trxLevel ) {
$this->query( 'COMMIT', $fname );
- $this->mTrxLevel = 0;
+ $this->trxLevel = 0;
}
}
final public function rollback( $fname = __METHOD__, $flush = '' ) {
if ( $flush === self::FLUSHING_INTERNAL || $flush === self::FLUSHING_ALL_PEERS ) {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
return; // nothing to do
}
} else {
- if ( !$this->mTrxLevel ) {
+ if ( !$this->trxLevel ) {
$this->queryLogger->error(
"$fname: No transaction to rollback, something got out of sync." );
return; // nothing to do
$this->assertOpen();
$this->doRollback( $fname );
- $this->mTrxAtomicLevels = [];
- if ( $this->mTrxDoneWrites ) {
+ $this->trxAtomicLevels = [];
+ if ( $this->trxDoneWrites ) {
$this->trxProfiler->transactionWritingOut(
- $this->mServer,
- $this->mDBname,
- $this->mTrxShortId
+ $this->server,
+ $this->dbName,
+ $this->trxShortId
);
}
- $this->mTrxIdleCallbacks = []; // clear
- $this->mTrxPreCommitCallbacks = []; // clear
+ $this->trxIdleCallbacks = []; // clear
+ $this->trxPreCommitCallbacks = []; // clear
try {
$this->runOnTransactionIdleCallbacks( self::TRIGGER_ROLLBACK );
} catch ( Exception $e ) {
* @param string $fname
*/
protected function doRollback( $fname ) {
- if ( $this->mTrxLevel ) {
+ if ( $this->trxLevel ) {
# Disconnects cause rollback anyway, so ignore those errors
$ignoreErrors = true;
$this->query( 'ROLLBACK', $fname, $ignoreErrors );
- $this->mTrxLevel = 0;
+ $this->trxLevel = 0;
}
}
}
public function explicitTrxActive() {
- return $this->mTrxLevel && ( $this->mTrxAtomicLevels || !$this->mTrxAutomatic );
+ return $this->trxLevel && ( $this->trxAtomicLevels || !$this->trxAutomatic );
}
public function duplicateTableStructure(
public function ping( &$rtt = null ) {
// Avoid hitting the server if it was hit recently
if ( $this->isOpen() && ( microtime( true ) - $this->lastPing ) < self::PING_TTL ) {
- if ( !func_num_args() || $this->mRTTEstimate > 0 ) {
- $rtt = $this->mRTTEstimate;
+ if ( !func_num_args() || $this->rttEstimate > 0 ) {
+ $rtt = $this->rttEstimate;
return true; // don't care about $rtt
}
}
$this->restoreFlags( self::RESTORE_PRIOR );
if ( $ok ) {
- $rtt = $this->mRTTEstimate;
+ $rtt = $this->rttEstimate;
}
return $ok;
*/
protected function reconnect() {
$this->closeConnection();
- $this->mOpened = false;
- $this->mConn = false;
+ $this->opened = false;
+ $this->conn = false;
try {
- $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname );
+ $this->open( $this->server, $this->user, $this->password, $this->dbName );
$this->lastPing = microtime( true );
$ok = true;
} catch ( DBConnectionError $e ) {
* @since 1.27
*/
protected function getTransactionLagStatus() {
- return $this->mTrxLevel
- ? [ 'lag' => $this->mTrxReplicaLag, 'since' => $this->trxTimestamp() ]
+ return $this->trxLevel
+ ? [ 'lag' => $this->trxReplicaLag, 'since' => $this->trxTimestamp() ]
: null;
}
}
public function setSchemaVars( $vars ) {
- $this->mSchemaVars = $vars;
+ $this->schemaVars = $vars;
}
public function sourceStream(
* @return array
*/
protected function getSchemaVars() {
- if ( $this->mSchemaVars ) {
- return $this->mSchemaVars;
+ if ( $this->schemaVars ) {
+ return $this->schemaVars;
} else {
return $this->getDefaultSchemaVars();
}
}
public function lock( $lockName, $method, $timeout = 5 ) {
- $this->mNamedLocksHeld[$lockName] = 1;
+ $this->namedLocksHeld[$lockName] = 1;
return true;
}
public function unlock( $lockName, $method ) {
- unset( $this->mNamedLocksHeld[$lockName] );
+ unset( $this->namedLocksHeld[$lockName] );
return true;
}
}
/**
- * Get the underlying binding handle, mConn
+ * Get the underlying binding connection handle
*
- * Makes sure that mConn is set (disconnects and ping() failure can unset it).
+ * Makes sure the connection resource is set (disconnects and ping() failure can unset it).
* This catches broken callers than catch and ignore disconnection exceptions.
* Unlike checking isOpen(), this is safe to call inside of open().
*
* @since 1.26
*/
protected function getBindingHandle() {
- if ( !$this->mConn ) {
+ if ( !$this->conn ) {
throw new DBUnexpectedError(
$this,
'DB connection was already closed or the connection dropped.'
);
}
- return $this->mConn;
+ return $this->conn;
}
/**
* @return string
*/
public function __toString() {
- return (string)$this->mConn;
+ return (string)$this->conn;
}
/**
if ( $this->isOpen() ) {
// Open a new connection resource without messing with the old one
- $this->mOpened = false;
- $this->mConn = false;
- $this->mTrxEndCallbacks = []; // don't copy
+ $this->opened = false;
+ $this->conn = false;
+ $this->trxEndCallbacks = []; // don't copy
$this->handleSessionLoss(); // no trx or locks anymore
- $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname );
+ $this->open( $this->server, $this->user, $this->password, $this->dbName );
$this->lastPing = microtime( true );
}
}
* Run a few simple sanity checks and close dangling connections
*/
public function __destruct() {
- if ( $this->mTrxLevel && $this->mTrxDoneWrites ) {
- trigger_error( "Uncommitted DB writes (transaction from {$this->mTrxFname})." );
+ if ( $this->trxLevel && $this->trxDoneWrites ) {
+ trigger_error( "Uncommitted DB writes (transaction from {$this->trxFname})." );
}
$danglingWriters = $this->pendingWriteAndCallbackCallers();
trigger_error( "DB transaction writes or callbacks still pending ($fnames)." );
}
- if ( $this->mConn ) {
+ if ( $this->conn ) {
// Avoid connection leaks for sanity. Normally, resources close at script completion.
// The connection might already be closed in zend/hhvm by now, so suppress warnings.
Wikimedia\suppressWarnings();
$this->closeConnection();
Wikimedia\restoreWarnings();
- $this->mConn = false;
- $this->mOpened = false;
+ $this->conn = false;
+ $this->opened = false;
}
}
}