From f0492a17150e915516a7be07fee2a3115df80ce6 Mon Sep 17 00:00:00 2001 From: sbassett Date: Wed, 4 Dec 2019 14:19:52 -0600 Subject: [PATCH] rdbms: Log debug message traces as 'exception.trace' instead of 'trace' Code cleanup and hardening (see also: T234014) of Database-related lib code in MediaWiki core. Bug: T233342 Change-Id: I3c968f4f5300374253dc80d99596cac50fbeb59e (cherry picked from commit 2e11b14455b44b8fcfd528da5efcc214902c2ffb) --- includes/libs/rdbms/database/Database.php | 12 ++++++------ includes/libs/rdbms/database/DatabaseMysqlBase.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 5f59f34822..d4fe59c279 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -1591,7 +1591,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware 'error' => $error, 'sql1line' => mb_substr( str_replace( "\n", "\\n", $sql ), 0, 5 * 1024 ), 'fname' => $fname, - 'trace' => ( new RuntimeException() )->getTraceAsString() + 'exception' => new RuntimeException() ] ) ); @@ -1618,7 +1618,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware "Error connecting to {db_server} as user {db_user}: {error}", $this->getLogContext( [ 'error' => $error, - 'trace' => ( new RuntimeException() )->getTraceAsString() + 'exception' => new RuntimeException() ] ) ); @@ -2430,7 +2430,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware if ( preg_match( '/(^|\s)(DISTINCT|JOIN|ON|AS)(\s|$)/i', $name ) !== 0 ) { $this->queryLogger->warning( __METHOD__ . ": use of subqueries is not supported this way", - [ 'trace' => ( new RuntimeException() )->getTraceAsString() ] + [ 'exception' => new RuntimeException() ] ); return $name; @@ -4208,7 +4208,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $this->queryLogger->warning( "$fname: Expected mass snapshot flush of all peer transactions " . "in the explicit transactions round '{$this->getTransactionRoundId()}'", - [ 'trace' => ( new RuntimeException() )->getTraceAsString() ] + [ 'exception' => new RuntimeException() ] ); } @@ -4329,7 +4329,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $fname . ': lost connection to {dbserver}; reconnected', [ 'dbserver' => $this->getServer(), - 'trace' => ( new RuntimeException() )->getTraceAsString() + 'exception' => new RuntimeException() ] ); } catch ( DBConnectionError $e ) { @@ -4880,7 +4880,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware public function __clone() { $this->connLogger->warning( "Cloning " . static::class . " is not recommended; forking connection", - [ 'trace' => ( new RuntimeException() )->getTraceAsString() ] + [ 'exception' => new RuntimeException() ] ); if ( $this->isOpen() ) { diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 464e68c410..84e9486d90 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -716,7 +716,7 @@ abstract class DatabaseMysqlBase extends Database { $this->getLogContext( [ 'method' => __METHOD__, 'age' => $staleness, - 'trace' => ( new RuntimeException() )->getTraceAsString() + 'exception' => new RuntimeException() ] ) ); } -- 2.20.1