From: Brad Jorsch Date: Fri, 27 Jun 2014 14:18:56 +0000 (-0400) Subject: Add $wgDebugDumpSqlLength X-Git-Tag: 1.31.0-rc.0~14783^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/File:%2A_image6?a=commitdiff_plain;h=053c3c5fd41f37a5a333b8746159a0fe96f46105;p=lhc%2Fweb%2Fwiklou.git Add $wgDebugDumpSqlLength When $wgDebugDumpSql is set, the logged queries are truncated to 500 bytes. This is often not enough if you're wanting to actually debug the queries instead of just seeing that queries were executed. Change-Id: Iad3abd20c11d647834aa5546a1a9c82916c6519f --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 86b7533b2d..4d248acc93 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -5000,6 +5000,13 @@ $wgDebugDBTransactions = false; */ $wgDebugDumpSql = false; +/** + * Trim logged SQL queries to this many bytes. Set 0/false/null to do no + * trimming. + * @since 1.24 + */ +$wgDebugDumpSqlLength = 500; + /** * Map of string log group names to log destinations. * diff --git a/includes/db/Database.php b/includes/db/Database.php index 3207a1b5ba..e13c053806 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1028,7 +1028,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * for a successful read query, or false on failure if $tempIgnore set */ public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) { - global $wgUser, $wgDebugDBTransactions; + global $wgUser, $wgDebugDBTransactions, $wgDebugDumpSqlLength; $this->mLastQuery = $sql; if ( $this->isWriteQuery( $sql ) ) { @@ -1102,7 +1102,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { static $cnt = 0; $cnt++; - $sqlx = substr( $commentedSql, 0, 500 ); + $sqlx = $wgDebugDumpSqlLength ? substr( $commentedSql, 0, $wgDebugDumpSqlLength ) + : $commentedSql; $sqlx = strtr( $sqlx, "\t\n", ' ' ); $master = $isMaster ? 'master' : 'slave'; @@ -1133,7 +1134,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { if ( $this->ping() ) { global $wgRequestTime; wfDebug( "Reconnected\n" ); - $sqlx = substr( $commentedSql, 0, 500 ); + $sqlx = $wgDebugDumpSqlLength ? substr( $commentedSql, 0, $wgDebugDumpSqlLength ) + : $commentedSql; $sqlx = strtr( $sqlx, "\t\n", ' ' ); $elapsed = round( microtime( true ) - $wgRequestTime, 3 ); if ( $elapsed < 300 ) {