$wgResourceLoaderMinifierMaxLineLength, because there was little value in
making the behavior configurable. The default values (`false` for the former,
1000 for the latter) are now hard-coded.
+* $wgDebugDumpSqlLength was removed (deprecated in 1.24).
+* $wgDebugDBTransactions was removed (deprecated in 1.20).
=== New features in 1.27 ===
* $wgDataCenterId and $wgDataCenterRoles where added, which will serve as
'PostgresBlob' => __DIR__ . '/includes/db/DatabasePostgres.php',
'PostgresField' => __DIR__ . '/includes/db/DatabasePostgres.php',
'PostgresInstaller' => __DIR__ . '/includes/installer/PostgresInstaller.php',
- 'PostgresTransactionState' => __DIR__ . '/includes/db/DatabasePostgres.php',
'PostgresUpdater' => __DIR__ . '/includes/installer/PostgresUpdater.php',
'Preferences' => __DIR__ . '/includes/Preferences.php',
'PreferencesForm' => __DIR__ . '/includes/Preferences.php',
*/
$wgDebugComments = false;
-/**
- * Extensive database transaction state debugging
- *
- * @since 1.20
- */
-$wgDebugDBTransactions = false;
-
/**
* Write SQL queries to the debug log.
*
*/
$wgDebugDumpSql = false;
-/**
- * Trim logged SQL queries to this many bytes. Set 0/false/null to do no
- * trimming.
- * @since 1.24
- */
-$wgDebugDumpSqlLength = 500;
-
/**
* Performance expectations for DB usage
*
* - 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 );
* @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"
);
}
}
-/**
- * Used to debug transaction processing
- * Only used if $wgDebugDBTransactions is true
- *
- * @since 1.19
- * @ingroup Database
- */
-class PostgresTransactionState {
- private static $WATCHED = array(
- array(
- "desc" => "%s: Connection state changed from %s -> %s\n",
- "states" => array(
- PGSQL_CONNECTION_OK => "OK",
- PGSQL_CONNECTION_BAD => "BAD"
- )
- ),
- array(
- "desc" => "%s: Transaction state changed from %s -> %s\n",
- "states" => array(
- PGSQL_TRANSACTION_IDLE => "IDLE",
- PGSQL_TRANSACTION_ACTIVE => "ACTIVE",
- PGSQL_TRANSACTION_INTRANS => "TRANS",
- PGSQL_TRANSACTION_INERROR => "ERROR",
- PGSQL_TRANSACTION_UNKNOWN => "UNKNOWN"
- )
- )
- );
-
- /** @var array */
- private $mNewState;
-
- /** @var array */
- private $mCurrentState;
-
- public function __construct( $conn ) {
- $this->mConn = $conn;
- $this->update();
- $this->mCurrentState = $this->mNewState;
- }
-
- public function update() {
- $this->mNewState = array(
- pg_connection_status( $this->mConn ),
- pg_transaction_status( $this->mConn )
- );
- }
-
- public function check() {
- global $wgDebugDBTransactions;
- $this->update();
- if ( $wgDebugDBTransactions ) {
- if ( $this->mCurrentState !== $this->mNewState ) {
- $old = reset( $this->mCurrentState );
- $new = reset( $this->mNewState );
- foreach ( self::$WATCHED as $watched ) {
- if ( $old !== $new ) {
- $this->log_changed( $old, $new, $watched );
- }
- $old = next( $this->mCurrentState );
- $new = next( $this->mNewState );
- }
- }
- }
- $this->mCurrentState = $this->mNewState;
- }
-
- protected function describe_changed( $status, $desc_table ) {
- if ( isset( $desc_table[$status] ) ) {
- return $desc_table[$status];
- } else {
- return "STATUS " . $status;
- }
- }
-
- protected function log_changed( $old, $new, $watched ) {
- wfDebug( sprintf( $watched["desc"],
- $this->mConn,
- $this->describe_changed( $old, $watched["states"] ),
- $this->describe_changed( $new, $watched["states"] )
- ) );
- }
-}
-
/**
* Manage savepoints within a transaction
* @ingroup Database
}
protected function query( $keyword, $msg_ok, $msg_failed ) {
- global $wgDebugDBTransactions;
if ( $this->dbw->doQuery( $keyword . " " . $this->id ) !== false ) {
- if ( $wgDebugDBTransactions ) {
- wfDebug( sprintf( $msg_ok, $this->id ) );
- }
} else {
wfDebug( sprintf( $msg_failed, $this->id ) );
}
/** @var string Connect string to open a PostgreSQL connection */
private $connectString;
- /** @var PostgresTransactionState */
- private $mTransactionState;
-
/** @var string */
private $mCoreSchema;
}
$this->mOpened = true;
- $this->mTransactionState = new PostgresTransactionState( $this->mConn );
global $wgCommandLineMode;
# If called from the command-line (e.g. importDump), only show errors
if ( function_exists( 'mb_convert_encoding' ) ) {
$sql = mb_convert_encoding( $sql, 'UTF-8' );
}
- $this->mTransactionState->check();
if ( pg_send_query( $this->mConn, $sql ) === false ) {
throw new DBUnexpectedError( $this, "Unable to post new query to PostgreSQL\n" );
}
$this->mLastResult = pg_get_result( $this->mConn );
- $this->mTransactionState->check();
$this->mAffectedRows = null;
if ( pg_result_error( $this->mLastResult ) ) {
return false;
* @throws MWException
*/
protected function getDB( $serverIndex ) {
- global $wgDebugDBTransactions;
-
if ( !isset( $this->conns[$serverIndex] ) ) {
if ( $serverIndex >= $this->numServers ) {
throw new MWException( __METHOD__ . ": Invalid server index \"$serverIndex\"" );
# If server connection info was given, use that
if ( $this->serverInfos ) {
- if ( $wgDebugDBTransactions ) {
- $this->logger->debug( "Using provided serverInfo for SqlBagOStuff" );
- }
$info = $this->serverInfos[$serverIndex];
$type = isset( $info['type'] ) ? $info['type'] : 'mysql';
$host = isset( $info['host'] ) ? $info['host'] : '[unknown]';
$db = wfGetDB( $index );
}
}
- if ( $wgDebugDBTransactions ) {
- $this->logger->debug( sprintf( "Connection %s will be used for SqlBagOStuff", $db ) );
- }
+ $this->logger->debug( sprintf( "Connection %s will be used for SqlBagOStuff", $db ) );
$this->conns[$serverIndex] = $db;
}