* - DBO_PERSISTENT: use persistant database connection
*/
public function setFlag( $flag ) {
- global $wgDebugDBTransactions;
$this->mFlags |= $flag;
- if ( ( $flag & DBO_TRX ) && $wgDebugDBTransactions ) {
- wfDebug( "Implicit transactions are now enabled.\n" );
- }
}
/**
* - DBO_PERSISTENT: use persistant database connection
*/
public function clearFlag( $flag ) {
- global $wgDebugDBTransactions;
$this->mFlags &= ~$flag;
- if ( ( $flag & DBO_TRX ) && $wgDebugDBTransactions ) {
- wfDebug( "Implicit transactions are now disabled.\n" );
- }
}
/**
* @param array $params Parameters passed from DatabaseBase::factory()
*/
function __construct( array $params ) {
- global $wgDBprefix, $wgDBmwschema, $wgCommandLineMode, $wgDebugDBTransactions;
+ global $wgDBprefix, $wgDBmwschema, $wgCommandLineMode;
$server = $params['host'];
$user = $params['user'];
if ( $this->mFlags & DBO_DEFAULT ) {
if ( $wgCommandLineMode ) {
$this->mFlags &= ~DBO_TRX;
- if ( $wgDebugDBTransactions ) {
- wfDebug( "Implicit transaction open disabled.\n" );
- }
} else {
$this->mFlags |= DBO_TRX;
- if ( $wgDebugDBTransactions ) {
- wfDebug( "Implicit transaction open enabled.\n" );
- }
}
}
* for a successful read query, or false on failure if $tempIgnore set
*/
public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
- global $wgUser, $wgDebugDBTransactions, $wgDebugDumpSqlLength;
+ global $wgUser;
$this->mLastQuery = $sql;
$commentedSql = preg_replace( '/\s|$/', " /* $fname $userName */ ", $sql, 1 );
if ( !$this->mTrxLevel && $this->getFlag( DBO_TRX ) && $this->isTransactableQuery( $sql ) ) {
- if ( $wgDebugDBTransactions ) {
- wfDebug( "Implicit transaction start.\n" );
- }
$this->begin( __METHOD__ . " ($fname)" );
$this->mTrxAutomatic = true;
}
}
if ( $this->debug() ) {
- static $cnt = 0;
-
- $cnt++;
- $sqlx = $wgDebugDumpSqlLength ? substr( $commentedSql, 0, $wgDebugDumpSqlLength )
- : $commentedSql;
- $sqlx = strtr( $sqlx, "\t\n", ' ' );
-
- $master = $isMaster ? 'master' : 'slave';
- wfDebug( "Query {$this->mDBname} ($cnt) ($master): $sqlx\n" );
+ wfDebugLog( 'queries', sprintf( "%s: %s", $this->mDBname, $sql ) );
}
$queryId = MWDebug::query( $sql, $fname, $isMaster );
*
* @return string
*/
- static function generalizeSQL( $sql ) {
+ protected static function generalizeSQL( $sql ) {
# This does the same as the regexp below would do, but in such a way
# as to avoid crashing php on some large strings.
# $sql = preg_replace( "/'([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\"/", "'X'", $sql );
* @throws DBError
*/
final public function begin( $fname = __METHOD__ ) {
- global $wgDebugDBTransactions;
-
if ( $this->mTrxLevel ) { // implicit commit
if ( $this->mTrxAtomicLevels ) {
// If the current transaction was an automatic atomic one, then we definitely have
) )
);
} else {
- // if the transaction was automatic and has done write operations,
- // log it if $wgDebugDBTransactions is enabled.
- if ( $this->mTrxDoneWrites && $wgDebugDBTransactions ) {
+ // if the transaction was automatic and has done write operations
+ if ( $this->mTrxDoneWrites ) {
wfDebug( "$fname: Automatic transaction with writes in progress" .
" (from {$this->mTrxFname}), performing implicit commit!\n"
);